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

Author Topic: Massive Memory Leak  (Read 24626 times)

0 Members and 3 Guests are viewing this topic.

zac

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Massive Memory Leak
« on: February 03, 2009, 03:42:29 pm »
There is a leak in heap memory, either in the classes Http or in one of the underlying classes. I am not using new or delete (despite for one single new/delete on begin/end of the program) in my program (downloading musics from lastfm), but it starts to use more and more heap space (memory field is heap). After ~200 MB of transferred data it uses ~40 MB ram (it begins with 2,2 MB)...
But I can't see where in the Http class it could be -.- all you use are C++-STL classes, I think.
I'll recheck my own code again and see if I can find a reason in there...

Ah:
I think I see now, it has most propably to do with the system cleaning up the memory allocated for the sockets or something similar, because the memory usage drops all of a shudden after reaching a high level (~50 MB) back down to ~6 MB. Seems very strange to me.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Massive Memory Leak
« Reply #1 on: February 03, 2009, 04:20:02 pm »
The OS does mostly not deallocate the memory instantly.

If you wait long enough, everything is freed again? For example, you could use a memory leak detector...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

zac

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Massive Memory Leak
« Reply #2 on: February 03, 2009, 07:29:08 pm »
It is okay like that... I think everything is freed as it should be, but with a little delay...
But 50 MB is clearly way bigger than the data downloaded at once^^ ;)
But it is hard to tell if everything is freed because the program surely does not stop downloading...
But for this small project (the code is definitely a quite dirty hack) that I will mainly use for myself it is absolutely okay.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Massive Memory Leak
« Reply #3 on: February 04, 2009, 01:35:00 pm »
That's what memory is for. :) Like Nexus said, operating system's memory managers mostly make high usage of memory caches. Instantly freeing and allocating memory would result in speed penalties. So as long as the proper memory is available, it'll be used as a cache, thus increasing performance.

You may want to checkout your program's memory usage when you're low on RAM. It shouldn't allocate too much of memory, then.

 

anything