openFrameworks icon indicating copy to clipboard operation
openFrameworks copied to clipboard

ofVideoPlayer macOS memory leak

Open stephanschulz opened this issue 7 years ago • 9 comments

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

stephanschulz avatar Jul 19 '18 20:07 stephanschulz

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...

gameoverhack avatar Jul 20 '18 06:07 gameoverhack

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

stephanschulz avatar Jul 20 '18 12:07 stephanschulz

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

stephanschulz avatar Jul 20 '18 13:07 stephanschulz

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

ghost avatar Oct 17 '18 19:10 ghost

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 avatar Apr 03 '19 18:04 dimitre

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 avatar Jun 24 '21 15:06 dimitre

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

dimitre avatar Jan 06 '22 12:01 dimitre

Was this ever fixed? We're running a video loop and the program crashes after a few hours. When we looked at the system memory over time it went from 6gb to 11gb over the play time of 11 hours. Using OF 0.11.2 osx release.

itsgalo avatar Dec 15 '24 19:12 itsgalo

@itsgalo please test with latest nightly to see if it still happens. are you using macOS? if yes I've fixed an infinite threads issue before 0.12.0 release

dimitre avatar Dec 15 '24 22:12 dimitre

@itsgalo I had the same kind of issue in the past, but not after 0.12. I'll be closing this one. Comment here if you have any similar issue with latest OF

dimitre avatar Nov 12 '25 15:11 dimitre