- Home /
www.texture memory leak
i did not manage to figure out why i have memory leak...i am trying to download certain image by button click and to display it in the gui...simple you might say! everything works except that i have memory leak, displaying around 10 images that are in ~150Kb in size makes ~1Gb memory increase...and it does not want to be freed...
here is the code:
 function DownloadImage(path : String,index : int){
 
     // Start a download of the given URL
     var www : WWW = new WWW(path); 
     
     // wait until the download is done
     yield www;
     
     if (www.error != null)
         debugData=www.error;
         
     if(www.isDone){    
         
         var _tTemp : Texture2D=new Texture2D(www.texture.width,www.texture.height);
         tImages=_tTemp;
         
         www.LoadImageIntoTexture(tImages);
         www.Dispose();
         www = null;
 
         
     }
     //set current image index
     currentImageIndex=index;
                             
     //set flag to true for image gallery
     showImages=true;
 
 }
only thing that works without memory leak if i directly use downloaded image without temporary texture like this (but then every second texture is displayed, and the ones that are not i get little question mark instead of a texture, trying again texture is correctly displayed!):
 function DownloadImage(path : String,index : int){
 
     // Start a download of the given URL
     var www : WWW = new WWW(path); 
 
     // wait until the download is done
     yield www;
 
     if (www.error != null)
         debugData=www.error;
 
     if(www.isDone){ 
 
         www.LoadImageIntoTexture(tImages);
         www.Dispose();
         www = null;
 
 
     }
     //set current image index
     currentImageIndex=index;
 
     //set flag to true for image gallery
     showImages=true;
 
 }
so: -using temp texture does give me memory leak but all textures are correctly displayed -without using temp texture i do not have memory leak but every texture failes to display (i get question mark instead of texture)
what is going on?
Answer by Graham-Dunnett · Nov 25, 2011 at 03:24 PM
Presumably you are downloading jpeg images, which are compressed. When you fetch these and use www.LoadImageIntoTexture() you'll get these images converted into raw pixels, so possibly 24-bits per pixel. The decompression of your images into formats that the GPU can deal with are probably responsible for the eating of memory, rather than a memory leak. The www.LoadImageIntoTexture() script reference does talk about this.
ok, but how to use that information to resolve this issue? i am out of ideas
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                