I am currently trying to locate a memory leak that was introduced in
version 0.4.0 of the SMPEG code, and has persisted into the current
0.4.5 pre-release code that is currently in the cvs archive. smpeg
0.3.5 was the last version of code in which plaympeg didn’t seem to be
leaking. Specifically if you run plaympeg -l , and watch either
top or ps -avx you can see that each time the mpeg loops it gains a bit
of memory. This is also true when an mpeg object is deleted after a
new. I tried using valgrind, it didn’t reveal anything useful. It
actually didn’t believe a leak existed. However, watching DRS and RSS
rise in value through ps -avx, I think proves it wrong.
I am grasping at straws here, and am in need of some direction. Can
anyone point me in the right direction.
Assuming that you run on Linux you may not actually have a memory leak
here. I have stumbled over a similar phenomenon a while back and it hit
me even worse (about 150kB every few seconds in a long-running program).
In fact the program did not have any memory leak I could find. Instead
it turned out that memory got fragmented. All the memory block that get
malloc()ed and free()d are junks out of a single big memory segment that
is grown/shrunk by the brk() syscall. The malloc library is just a very
complex and optimized wrapper around this syscall.
This all means that memory can’t always be given up in situations like that:
If j got allocated “behind” i it doesn’t matter whether i gets freed or
not, since the existance of j blocks the heap from shrinking. If j is
freed later on the memory consumed by i will be given back to the
system, too.
Hope that helps.
Gregor
Robert Diel wrote:> I am currently trying to locate a memory leak that was introduced in
version 0.4.0 of the SMPEG code, and has persisted into the current
0.4.5 pre-release code that is currently in the cvs archive. smpeg
0.3.5 was the last version of code in which plaympeg didn’t seem to be
leaking. Specifically if you run plaympeg -l , and watch either
top or ps -avx you can see that each time the mpeg loops it gains a bit
of memory. This is also true when an mpeg object is deleted after a
new. I tried using valgrind, it didn’t reveal anything useful. It
actually didn’t believe a leak existed. However, watching DRS and RSS
rise in value through ps -avx, I think proves it wrong.
I am grasping at straws here, and am in need of some direction. Can
anyone point me in the right direction.