- Home /
Memory leak on video players?
I'm creating a gallery-like feature within an app. Users can swipe left and right like on a native iOS gallery. When swiping and snapping to a new image/video, if it is a video, it will load the video by setting a url on a Unity VideoPlayer. However, I noticed that even from telling previous videoplayers to .Stop(), it doesn't actually deallocate memory. So with sufficient usage, the gallery in the app causes a memory crash.
Is there another explicit way to force a VideoPlayer to free its memory? Is this a bug? If there is no workaround, I would also be happy to use a more stable video player, even if it's not free.
I'm on Unity 2018.1.2f1
Having the same Issue in on iOS 12 with Unity 2019.1.4f1 and would really appreciate some insights into this.
Having similar issues - nothing seems to be freeing up the memory
Answer by MartinTilo · Aug 23, 2019 at 06:48 PM
Can you check the memory usage in the Memory Profiler Package (in case you updated to 2018.3 or LTS) or the memory Profiler Module of the Profiler window by going to detailed view and taking a snapshot? The new packaged Memory Profiler should be able to tell you what still holds a reference to the video and therefore keeps it in memory. Generally speaking though, without knowing any details of your implementation, it sounds like a bug/leak in the VideoPlayer since the documentation clearly states that UnityEngine.Video.VideoPlayer.Stop should release buffers and native resources. You'll still have the Video Player Component around so if you're not reusing that but add a new component for each video, that could be another source for a leak in your code.
Your answer
Follow this Question
Related Questions
'Done' button missing | Video Playback iOS 9.2 2 Answers
Assetbundle memory leaks 0 Answers
VRam keeps climbing until Unity editor crashes. 1 Answer
"Real Memory" usage in iOS expands the more often one prefab is referenced in the assetbundle 0 Answers
[iOS] AssetBundle.LoadFromMemoryAsync leak memory? 0 Answers