Yalir / sfeMovie

sfeMovie is a simple C++ library that lets you play movies in SFML based applications. It relies on FFmpeg to read medias and remains consistent with SFML's naming conventions.
http://sfemovie.yalir.org/
GNU Lesser General Public License v2.1
114 stars 37 forks source link

Memory leak? #90

Closed rvbiljouw closed 8 years ago

rvbiljouw commented 9 years ago

I can't seem to pinpoint exactly where things are going wrong, but when playing multiple videos one after another it seems that the memory allocated for each video is retained...

Maybe I'm just doing something really stupid but I've been hitting the same issue for a while now and I'm struggling to find where the problem is.

Code sample: https://gist.github.com/rvbiljouw/39cb54df0b6d63f4380d

Ceylo commented 9 years ago

Hi, do you notice any difference when executing within and out of any debugger? And with same file format & codec vs different file format & codec?

rvbiljouw commented 9 years ago

I don't see any difference between running it through a debugger (gdb) or just by itself. I only use the h.264 codec encoding in production but I'm going to see if the same thing happens when running solely off of h.262 and see if that makes a difference.

feliwir commented 9 years ago

Hi, can you maybe run your application via valgrind? It would tell us if the memory leak is somewhere in your code or in sfeMovie. Thanks

rvbiljouw commented 9 years ago

Apologies, I've been on holiday so didn't have the chance to get back to this issue..

@feliwir: I've gisted a valgrind memcheck logfile here: https://gist.github.com/rvbiljouw/1ebec7417d2e3cbe2891

Problem is still occurring, I hope we can figure out why :(

Ceylo commented 9 years ago

No worries, it was vacations here too :)

I checked your valgrind report and looked at the leaks reported at the end (the biggest ones). Some look to come from FFmpeg which look to allocate some buffer once and never free them. I guess these are on purpose and are only allocated once, so they would not be the culprit in your case.

At the moment I don't even know if the issue comes from FFmpeg, sfeMovie or SFML or some other dependency. About your sample code, can you provide a self-contained minimalist source program so that we're sure to reproduce the same issue?

rvbiljouw commented 9 years ago

Yep, I'll work on getting a sample program together this weekend. Some interesting thing that came up from experiments is that I can't seem to reproduce the memory leak (or at least not as severe) on windows, so there's a chance that the issue stems from dodgy graphics drivers (fglrx) under Linux.. Will update when I know more.

Ceylo commented 8 years ago

Actually thanks to http://sfemovie.yalir.org/forum/viewtopic.php?id=50 I've been able to reproduce a leak. It looks similar to your: happening after reloading new media files.

Ceylo commented 8 years ago

I've pushed a fix on branch bugfix/90+91_LeakOnReload You can also find debug binaries with all decoders here:

Could you test for the OS you use and tell me if it's ok on your side too?

Ceylo commented 8 years ago

Fix has been reported to be ok on forum so I merge to master and close this issue.