- Home /
Memory consumption after Texture2D.LoadImage and Destroy texture
Hi, I met very strange behaviour about memory used after load png to texture and destoy it. I test it only on iOS with Unity 5.4.4f1. Unity profiler doesn't show anything wrong, but if I check memory by Instruments/activity monitor it is very strange.
I start empty scene and it take about 30MB After I load png image by Texture2D.LoadImage (2kx4k img, loaded size ~43MB) memory consumption increase to ~80MB. After destory texture and set pointer to null (and call GC.Collect), memory consumption is about 40MB (at this point is increased reserved memory in Unity profiler about 10MB and all seem OK). After l load same image again , memory consumption increase to ~115MB. After destroing texture, memory consumption is 73MB (and Unity profiler show same numbers as after first destoy step - its not good).
next load and destroy texture does'n increase memory any more (stop on ~115 vith loaded texure and 73MB with unloaded texture).
Loading texture directly from resources (resources.Load) work without any trouble. I try search issue Tracker and don't found only this: https://issuetracker.unity3d.com/issues/destroying-texture2d-doesnt-free-memory but it's set as fixed in past.