How to clean Memory from array of textures ??
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement