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
1
Question by robertbu · Jul 27, 2012 at 07:07 AM · texturewwwmemory

Why do larger www textures take huge amounts of memory?

I'm downloading jpegs from the net and setting them as textures. In looking at the statistics window memory usage grows far faster than I would expect. For example the statistics for Used Textures for the following sizes:

 A) 1024 x 1024  = 3 MB
 B) 2048 x 2048 = 12 MB
 C) 3072 x 3072 = 64 MB
 D) 4096 x 4096 = 256 MB

The jump from A to B is exactly what I would expect, but the 5x jump from B to C and the 4x jump from C to D seems way out of line. Anyone know what larger texture loads use so much more memory? And can I do anything about it?

Note this was tested in the editor with a new project containing only a camera, a sphere, a material, and the following simple code (just changing the jpeg loaded):

 void Start ()
  {
  StartCoroutine("Load");
  }
  
  IEnumerator Load()
  {
  string st = "http://www.mysite.com/A.jpg";
  
  WWW www = new WWW(st);
  yield return www;
  
  renderer.material.mainTexture = www.texture;
  }
Comment
Add comment · Show 4
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 Kryptos · Jul 27, 2012 at 08:00 AM 0
Share

Could be related to mipmapping and/or the fact that some hardware do not support texture size greater than 2048, so they need to be handled differently.

Do all your textures use the same format? (for example ARGB)

avatar image robertbu · Jul 27, 2012 at 02:16 PM 0
Share

The issue occurs inside the editor with "PC and $$anonymous$$ac" standalone as the targets. The texture is loaded through the www interface, and I cannot figure out how to deter$$anonymous$$e the format it provides. I've considered mipmapping as a possibility, but other posts indicate that textures handed back by the WWW interface are not mimmapped.

avatar image Kryptos · Jul 27, 2012 at 02:33 PM 0
Share

You can check that with Texture2D.format and Texture2D.mipmapcount.

 WWW www = new WWW(st);
 yield return www;

 if (www.texture != null)
 {
     Texture2D tex = www.texture;
     Debug.Log("format: "+tex.format.ToString()
         +"mipmapCount: "+text.mipmapCount);
 }

See also: WWW.LoadImageIntoTexture

avatar image robertbu · Jul 27, 2012 at 03:31 PM 0
Share

Thanks for the info. The format is RGB24 and mipmapCount is 1 (i.e. no mipmaps). Just to be sure, I tried

 Texture2D t2d = new Texture2D(4096, 4096, TextureFormat.RGB24, false);
 www.LoadImageIntoTexture(t2d);

The large memory usage is the same. This indicates to me the large memory usage is either inherent in Unity or a bug in Unity.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by ScroodgeM · Jul 28, 2012 at 05:58 PM

first. don't test texture memory usage on textures with size non-power-of-two (NPOT). those textures takes more space then (height x width x bpp). try always use only POT textures for 3d rendering and especially for measurement.

second. look script below. it takes exactly 48MB of textures memory usage. feel free to use texture in script. may be your format is incorrect?

in other textures everything is same as yours result. 1024x1024 takes 3MB, 2048x2048 - 12MB, 3072x3072 - 64MB (see above), 4096x4096 - 48MB

if you still get 256B with my 4096x4096 texture, describe your measure method.

void Start() { StartCoroutine("Load"); }

 IEnumerator Load()
 {
     string st = "http://zammyart.com/4096.jpg";

     WWW www = new WWW(st);
     yield return www;

     Texture2D t2d = new Texture2D(4096, 4096, TextureFormat.RGB24, false);
     www.LoadImageIntoTexture(t2d);

     renderer.material.mainTexture = t2d;
 }</pre>

Comment
Add comment · Show 2 · 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 robertbu · Jul 28, 2012 at 08:02 PM 0
Share

You are right on the 4$$anonymous$$ image. $$anonymous$$y large test image was a couple of pixels too large. I still don't understand why a 3$$anonymous$$ x 3$$anonymous$$ image is larger than a 4k x 4$$anonymous$$ image. At worst, I would have expected them to be the same size, not have the 3$$anonymous$$ image so much larger. Thank you for spending the time to check this out.

avatar image ScroodgeM · Jul 28, 2012 at 08:06 PM 0
Share

if texture size is NPOT, it can be converted (i'm not sure about this) to POT size for 3D adapter and also kept original copy in memory for future usage. so it can take more memory then 4$$anonymous$$ texture.

just don't use NPOT textures 8)

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What is the correct way to remove assets from memory? 1 Answer

Free memory after WWW.LoadImageIntoTexture 1 Answer

Large memory footprint increase when assigning a GUITexture from a WWW Object on iPad 1 Answer

Loading imagesequence at runtime - memory problem 1 Answer

Memory problem with WWW and Texture 2 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