Playing multiple video in succession cause memory leak?

So I have been making a project for 360 video playing for VR.
I make a function to extract frame and save it as png for thumbnail.
I basically use frame-ready callback of video player, prepare and then pause to deliver the frame, then save it.
The function loop to all videos in a given directory.

I noticed as soon as I press play and the function started, my GPU VRAM usage is maxed out in Task manager. However different story when I checked using unity profiler that the VRAM usage detected is only 12 MB.
I already test by disabling some fuinctions like converting textures, saving texture to PNG, nothing solve the high VRAM usage, only when I disabled the videoplayer, there is no high memory usage.
I also stop the videoplayer as soon as I save the PNG I also try to destroy the videoplayer and recreate it, but nothing help.

Also the VRAM is never release unless I close the Unity Editor. Even if I stop the play mode.
Also How much accurate is the profiler?

I attached the script for the thumbnail creator.
I use Unity 2019.4.17f1

6752287–778855–Assets_Script_ThumbnailCreator.cs (6.23 KB)

Hi!
I am also facing the same issue. Did u find any solution?

Also, similar to your case, I was building the app for google cardboard(VR) but later I moved to a pc build instead. Although, I removed all scripts related to the VR version, the plugins(for google cardboard) still exist . Is it possible that I am facing this issue because of that.

Thanks

The best solution I got to get around this issue to either downgrade the unity version or try another version of unity. This seems like a bug in some Unity version.
Last time I tried, 2018 didn’t have this issue, some 2020 have this issue too when I tried to upgrade the Unity that time.
Unity 2021 however I haven’t try, it might already fixed on that version.

1 Like

Thanks for the reply. Although I cannot change to other version of Unity as you suggested, I got a method to work for me. Transcoding the video with the vp8 codec seems to do the trick for me.

Oh great! I will keep that in mind in case I encounter this problem again.

1 Like