Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by pretender · Nov 25, 2011 at 03:12 PM · texturetexture2dwwwdownloadmemory leak

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pretender · Nov 26, 2011 at 12:48 PM 0
Share

ok, but how to use that information to resolve this issue? i am out of ideas

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Where is downloaded things from editor script being saved? 0 Answers

www.texture different in editor and on webplayer 1 Answer

www download strange...help 0 Answers

cant get Texture2D.LoadImage() to work 0 Answers

How to load interlaced streamed image into a texture? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges