openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.97k stars 2.55k forks source link

ofVideoPlayer macOS memory leak #6085

Open stephanschulz opened 6 years ago

stephanschulz commented 6 years ago

Using the video player example I am calling load every 10 seconds. Over time the memory builds up. I'm on macOS 10.12 with latest of_v0.10.0_osx_release.

Please look at screen shot to see file size, memory usage and load count.

screen shot 2018-07-19 at 4 44 24 pm

gameoverhack commented 6 years ago

Can you try running the program just as an application outside of XCode? Ie., Just double click the compiled app and monitor memory usage using the activity monitor. It may be a new/unrelated bug, but when I was developing a HAP AVFoundation add-on I chased a suspected memory leak for weeks only to discover that it was actually a bug with Xcode and video - the memory leak only occured when executing the app from Xcode...

stephanschulz commented 6 years ago

Same problem even without Xcode. Strange that loading a 340 MB video file with raw codec creates 80 MB memory increases.

stephanschulz commented 6 years ago

I tried it also with OF 0.9.8 and on a different computer and see the same results. I guess since my video is very large I only notice it now and never before with much smaller files. But even smaller files (20MB) exhibit a slow memory build up.

In case someone wants to verify my findings. Here are my simple code and the video I'm testing with. https://www.dropbox.com/s/qj2fayxgs7m8dq7/videoPlayerExample.zip?dl=0

ghost commented 6 years ago

I can confirm the leak in Linux, ubuntu 16.04. Using the same example but switching between two different video Files. Memory usage continues to grow.

@arturoc @roymacdonald

screenshot from 2018-10-17 21-55-13 screenshot from 2018-10-17 21-55-22 screenshot from 2018-10-17 21-55-55

dimitre commented 5 years ago

I've built a custom video player that runs everyday, loading a new video each 10 seconds, and it freezes the computer after about 12 or 13 hours. Maybe it is related to this issue. I'll try to load a vector of videos to avoid calling load function a thousand times and see if it runs OK.

dimitre commented 3 years ago

I'm just linking a forum post that seems to run on the same issues described here: https://forum.openframeworks.cc/t/memory-increases-at-each-rerun-how-to-free-it/37972/11

dimitre commented 2 years ago

Hello @stephanschulz can you please try it again with the latest master? There are some recent changes in AVFoundationVideoPlayer which can help.

Screen Shot 2022-01-06 at 09 35 47