Open se7enXF opened 1 year ago
It's probably because ffmpeg started before it finished processing and it's still there.
Make sure it is stopped with FfmpegCommand.IsRunning
or FfmpegCommand.IsFinished
before trying to start it.
@NON906
We tested v2.1, v2.7, v2.9 of FFmpeg for Unity. The test result is that only the v2.1 does not have Memory leak. The current situation is that higher versions not only do not release memory after recording, but also occupy a high CPU usage, forever. V2.1 will release memory and cpu after recording.
How did you check? I want to check it here as well.
@NON906
Using my script and create two button on UI, one for StartRecord and another for StopRecord. Just run Linux build on Ubuntu20.04, using top to monitor memory and CPU. You can first click StartRecord, wait for seconds, then click StopRecord. Loop the action and watch the changes in memory usage.
I checked %CPU and %MEM with the top command, but they did not remain after stopping.
@NON906
Which version? I need to check again.
Unity 2021.3.16f1 FFmpeg for Unity 2.9 Ubuntu 20.04.6 LTS
Confirmed with Editor and IL2CPP build.
@NON906 I tested v2.7 and v2.9 with IL2CPP build. v2.7 has no memory leak but v2.9 has minor memory leaks. What's more, I have other plugins only support Mono build in my project, so IL2CPP is not working for me. I am now working on combining v2.1 with #2 to avoid segmentation fault. If you can solve the memory leak problem in Mono build, that would be very grateful!
I use FfplayCommand and FfmpegCaptureCommand as follow:
In windows editor, if you call PlayVideoFile() and StopPlay() or StartRecord() and StopRecord() many times, there is no memory leak.
In linux build, invoking 10 times StartRecord(), PlayVideoFile(), StopPlay() and StopPlay() will result in about 1GB of memory leakage. Here is the error code. Onec the issue occurres, the errors will loop to print many times :