• Advertisement
Sign in to follow this  

How to clean Memory from array of textures ??

This topic is 4335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi guys ,i am using an array of textures to load my images to memory Texture[] MyTextureArray=new Texture[90] but the problem is that when i want to delete this array by putting MyTextureArray=null; the memory stays the same and do not decrease !! i tried to gc.collect and gc.supressfinalize(MyTextureArray) but still the memory won't decrease, in my project i need to load images always so when i load the first 90 image i need to delete them and load another and so on , so if i do it 3 or 4 times the memory will become full and this is bad !! could the problem be in the way i am loading the textures ??? here is how i load my textures MyTextureArray=textureloader.fromfile(device,imagepath , 600,600,0,0,format.unknown,pool.default,filter.linear,filter.point,0) thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
As there are unmanaged objects behind the managed objects you have to call Dispose for each of them before you load a new one.

This is a general rule in .net: If an object supports Dispose you should call it as soon as you don’t need this object anymore.

Additional stay away from the GC methods as long as you don’t know exactly what the do. The can cause a very bad performances behavior or even more worse memory leaks.

Share this post


Link to post
Share on other sites
thanks 4 ur reply "Demirug" i was confused coz texture array don't have a dispose method so i did it for each texture in the array :) thanks again

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement