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 busychild · Jun 21, 2012 at 06:52 PM · iostexturetexture2dmemorymemory-leak

Loading external Image as Texture2D increases memory consumption dramatically on iOS

Hi folks,

i've a weird problem with loading external images as textures because the memory consumption increases unacceptable .

I'm currently loading about 100 images:

 IEnumerator loadTexture(string url, GameObject cube) {

     _textureURL = "file://" + Application.dataPath + "/../../Documents/webcontent/app/media/" + url; 
     _www = new WWW(_textureURL);
     yield return _www;
     _tempTexture = new Texture2D(256, 256);
     _www.LoadImageIntoTexture(_tempTexture);
     cube.renderer.material.mainTexture = _tempTexture;
 }


The whole images are using approximately 2-3MB of disc space but if i run the profiler i can see that these images are using more than 200MB of memory! What's going on there?

I also tried to initialize the Texture2D with different texture formats but this is not working as well just as loading the assets via the "System.IO.File.ReadAllBytes"-method and then load it on the texture (_tempTexture.LoadImage(textureBytes).

Thanks in advance for your help!

Comment
Add comment · Show 12
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 whydoidoit · Jun 21, 2012 at 06:56 PM 0
Share

Are your images power of 2 dimensions?

avatar image busychild · Jun 21, 2012 at 06:59 PM 0
Share

No, but i've tried it with an image which is (loaded these image 100-times) - the result was the same but just in case i will give it one more try!

avatar image whydoidoit · Jun 21, 2012 at 07:02 PM 1
Share

If they aren't power of two dimensions then it will get much bigger due to buffer allocations. Bear in $$anonymous$$d images in memory are always massively bigger than jpg or png files as those are compressed file formats.

avatar image busychild · Jun 21, 2012 at 07:09 PM 0
Share

Ok thanks! I've tried it but it turns out that a 512px x 512px .png image increases the memory much more than the other images. Here are the results from the profile:

  1. Before loading the external images: http://www.equalion.de/help/before.jpg

  2. After loading the external images: http://www.equalion.de/help/after.jpg

BTW: The .png image is using 101kb of disc space and i know that uncompressed images are getting bigger in memory than compressed ones but i can't believe that it increases from 10$$anonymous$$B disc space (100 * 101kb) to more than 400$$anonymous$$B in memory...

avatar image whydoidoit · Jun 21, 2012 at 08:40 PM 0
Share

No the in memory size of your images is around 103$$anonymous$$B as a guess - one 512x512 image takes just over 1$$anonymous$$B of ram. The rest will be buffers etc used to import the image I imagine (it really is very costly). However, just because the OS profiler says you have that much memory does not mean that the application is using it - it can be allocated but not garbage collected yet.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Can I load textures at runtime with a smaller memory footprint? 1 Answer

Unloading asset bundles doesn't clear memory on iOS 1 Answer

Textures/Atlases and memory management 0 Answers

iPad real memory accumulation, how to prevent this? 1 Answer

Bug - Texture "corrupted" after sending on server with MultipartformDataSection, only on iOS 1 Answer


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