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 DevMac1 · Mar 06, 2014 at 09:17 AM · wwwtexturesmemorypng

Double memory for textures downloaded with www.....

So, here is my problem!

I have some png images in app directory on device

I use this code to load each texture

 www = new WWW("file://" + Application.persistentDataPath + "/Folder/img.png");
 yield return www;
 Texture2D texture = www.texture;

 int MemoryForTexture = texture.width * texture.height * 32; // for debug

 www.Dispose ();
 www = null;

When I check memory usage in profiler, It looks like total memory usage for texture is MemoryForTexture*2! Could you help me with this problem? Why my texture use double memory?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by GameVortex · Mar 06, 2014 at 09:55 AM

The memory used for a texture is not width height 32. The memory used is depending on the format of the texture. JPG will be loaded as RGB24 which has a memory usage of approximately width height 3 (R, G and B). PNG will be loaded as ARGB32 which has a memory usage of approximate height width 4 (R, G, B and A). These are not absolute and memory usage may vary.

I am not sure how you check in the profiler how much memory the one texture you load uses, but the profiler is not accurate in this behaviour specifically when you profile the game in the editor. You get somewhat more accurate results when profiling a build.

Comment
Add comment · 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
0

Answer by DevMac1 · Mar 06, 2014 at 10:09 AM

I profiling my build in Xcode profiler on real device!

All my png are loaded as ARGB32!

int MemoryForTexture = texture.width texture.height 32; here I get memory in bits!

First, I load empty scene to check, how much memory it use! It is about 80 MB!

Then I launch script, which load textures! There is no other objects in scene! Only Camera! And script, which load textures in memory! So I can see the difference in memory usage! So, I have MemoryForTextures, which show me size of all downloaded textures in bits (or bytes)! And I have statistic of memory usage in Xcode profiler! For example, if all my textures are 40 Mb, in profiler I have 160Mb of memory usage! So 160 - 80 (in empry scene) = I get 80 Mb! But it should be 120 Mb!

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 GameVortex · Mar 06, 2014 at 10:51 AM 0
Share

You really like exclamation points don't you? =) You should by the way not post comments as answers.

I understand now, you are calculating memory in bits ins$$anonymous$$d of bytes. You are also on an IPhone or IPad and are using the XCode Profiler, which is information I would recommend you to include in the question itself.

I unfortunately do not know why the XCode profiler reports double memory usage. It may have to do with garbage collection or memory allocation. On a standalone pc build the Unity profiler shows the correct memory usage for my textures.

$$anonymous$$aybe you could try connecting the Unity Profiler to the build and see what it reports?

avatar image whydoidoit · Mar 06, 2014 at 11:59 AM 1
Share

The Xcode memory profiler can be dodgy over actual memory usage. Some memory needs double counting on iOS due to the fact it exists in main memory and again for the video device. It depends which XCode tool you use as to what you actually see.

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

22 People are following this question.

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

Related Questions

Why do larger www textures take huge amounts of memory? 1 Answer

the texture appear rubbish 1 Answer

App Crashing on iPhone due to Texture Memory 2 Answers

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

Memory question regarding textures android 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