Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Possible memory leak  (Read 2033 times)

0 Members and 1 Guest are viewing this topic.

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Possible memory leak
« on: February 29, 2012, 02:33:32 am »
Hello,

Recently I noticed a memory leak in my applications, so I tried to track it down and I think there is something wrong with two SFML functions.

So, my applications were simply ALWAYS allocating memory. Like 4KB/s, by watching the task manager.

I started to look for the problem, and i narrowed it down to this piece of code:

Code: [Select]
if(myWindow && activeDrawing){
myWindow->SetActive(true);
myWindow->Clear(clearColor);
onRender();
myWindow->Display();
}


That is my "render loop". If i comment those 4 lines,the memory does not increase at all.

Otherwise, it goes nuts. Clear() doesn't seem to do harm, however, Display() is consuming the most. SetActive() is also consuming memory from time to time, but way less than Display().

Can you please discuss this?

EDIT: I was unable to reproduce the problem with a minimal application, therefore i don't really understand why that couple of functions are having that effect while commenting them actually works, in the context of the other app.

Tex Killer

  • Full Member
  • ***
  • Posts: 242
    • View Profile
Possible memory leak
« Reply #1 on: February 29, 2012, 03:09:37 am »
How is your onRender function?

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Possible memory leak
« Reply #2 on: February 29, 2012, 03:23:49 am »
empty, as i was just looking for the problem..

Tex Killer

  • Full Member
  • ***
  • Posts: 242
    • View Profile
Possible memory leak
« Reply #3 on: February 29, 2012, 06:00:01 am »
Try making a copy of your project and removing a part of the other code (not the one that you posted here) at a time, checking if the leak remains. That way you will have either a minimal example code for us or the solution.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Possible memory leak
« Reply #4 on: February 29, 2012, 08:00:08 am »
It might be a problem with the graphics driver. You're not the first one to report such a leak, and we could never find anything in SFML.
Laurent Gomila - SFML developer

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Possible memory leak
« Reply #5 on: February 29, 2012, 12:27:47 pm »
Its really weird, I did comment all my code by parts, just until i could narrow the leak down to one function..

Commenting those lines does solve it, and the code im running is as simple as it gets in my framework, nothing special is happening in it.

However a simple sfml snippet works..

I did have a Nvidia crash yesterday. In one of the runs when i was tracking the issue, the memory consumption increased suddenly by a few MB and i got a black screen. After that, I could see a error:

Nvidia graphics driver connection with the software was lost, therefore the application must be closed. (Something like this)

And then everything went back to normal..

I bet its related to initializing other libraries too, but I need more testing and I can't right this time :)