Sign in to follow this  
jad_salloum

How to clean Memory from array of textures ??

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[i]=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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this