NewChromantics / PopH264

Low-level, minimal H264 decoder & encoder library for windows, hololens/uwp, ios/tvos/macos, linux, android/quest/magic leap. CAPI for use with c#, unreal, swift
http://poph264.com/
Mozilla Public License 2.0
84 stars 15 forks source link

Memory Leak on with Texture2Ds #59

Open Changliu52 opened 3 years ago

Changliu52 commented 3 years ago

Problem of not able to delete decoded images on windows still persist. All the received images stay in the memory. It takes about 10 mins to build up my entire 48 GB memory.

This is about 3 mins into the runtime. MicrosoftTeams-image

Any suggestion to fix the bug?

SoylentGraham commented 3 years ago

Unity doesnt garbage collect Texture2D's properly, so if you're not re-using textures passed into GetNextFrameAndMeta(), you need to manually destroy them with Texture2D.DestroyImmediate(texture, true); when you're finished using them

here is where it only allocates new textures if you haven't passed some in https://github.com/NewChromantics/PopH264/blob/master/Unity/PopH264/Assets/PopH264/PopH264.cs#L247