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
2
Question by awall · Feb 18, 2013 at 11:09 PM · iostexturememoryprofiler

Determining Texture Memory Usage

I'm currently trying to port a game to iOS and running into memory issues. I know that the game is pretty liberal with memory usage, and I'd like to track down the biggest offenders so I can clean them up. However, running the profiler produces results that I don't quite understand, and I was hoping somebody could help me shed some light on what they mean.

Here's what I see when I look at the memory usage reported by the profiler on the iOS build from within the editor:

Total: 180.7 MB **Textures: 1127 / 65.3 MB** Meshes: 596 / 0.9MB Materials: 261 / 102.9 KB AnimationClips: 0 / 0 B AudioClips: 16 / 3.4 MB Assets: 2206 GameObjects in Scene: 764 Total Objects in Scene: 4232 Total Object Count: 6438

This claims that I'm using far more memory than I would have expected on textures. However, when I look at the same scene using Resource Checker, what I see is much closer to what I expect:

  • 25 Textures total, whose combined sizes are 14.03 Mb

  • 3 textures that are 2048x2048 RGBA Compressed PVRTC 4 bits, each taking up 2.0Mb

  • 7 textures of various non-power-of-two dimensions. They aren't compressed, but they're also not particularly large; they range in size from 556k to 750k.

  • 5 textures that are 1024x1024 RGBA Compressed PVRTC 4 bits, each taking up 512k

  • 9 remaining textures that are all power-of-two sizes between 4x4 and 512x512. None of these take up more than 256k.

I can't find any objects in my scene that are using a texture that isn't one of these 25. This leaves me with two primary questions:

1) What are the other 1121 textures that the profiler claims that I'm using? Are these textures being used by the editor? If so, how can I get a better sense of where my memory is actually being used on device?

2) The profiler claims that I'm using 180.7 MB total, but the breakdown below only adds up to around 70 MB. Where is the extra 110 MB coming from?

Thanks for any help.

Comment
Add comment · Show 8
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 gdeglin · Mar 07, 2013 at 07:16 AM 0
Share

Hi Awall. Did you ever figure this out? Going to be digging into profiling my own app soon and want to be prepared in case I run into a similar issue.

avatar image sparkzbarca · Mar 07, 2013 at 09:28 AM 0
Share

total does i'm pretty positive include the heap (unallocated memory) That is to say basically cause your running on a modern computer unity asked for some memory and your computer handed it 180mbs. It could have handed it less but saw so no need.

The largest issue is i'm fairly positive compressed textures aren't compressed in the default build. they get compressed once you build the exe. As such you are currently working with uncompressed 2048 x 2048 textures. (im not sure the size but you can look it up, basically check if going from 14mb to 70 makes sense IF those textures werent compressed add those values up as uncompressed).

The 1127 I believe just references how many objects are referencing a texture (your only using 16 textures but each texture is being used hundreds of times)

Basically you need to try to reduce the texture size and compile to an exe and maybe try changing the type of texture. (do you need RGBA for example, because RGBA includes an alpha transparency layer, are your textures partially tranparent? if they are fuly visible you should use a format that doesn't include a transparency channel.)

avatar image MountDoomTeam · Mar 07, 2013 at 11:40 AM 0
Share

nice one, that didn't really read like a question!

avatar image awall · Mar 07, 2013 at 05:41 PM 0
Share

@gdeglin: No, I didn't really figure this out. I eventually lost faith in the profiler after it started giving me readings that were obviously incorrect (for example, as a test, I tried calling Resources.UnloadUnusedAssets() every frame; this caused Total memory usage to gradually drop... and drop... and drop... all the way down to 0.) Ins$$anonymous$$d, I looked at the Editor Log after a build, which shows you the size of all of the resources built into your game; it's not exactly what I was looking for, but it showed me that there were quite a few textures being built into some of my scenes than I'd thought, so I was able to improve things that way.

@sparkzbarca: Thanks for the explanation. As I mentioned above, I've found the profiler to be generally unreliable, but your comment would explain some of the strange data that I was seeing.

avatar image Essential · Jun 05, 2013 at 09:58 PM 0
Share

Did you ever figure out why it was giving these figures? I'm getting the same issue on my end… overblown textures. Only the compressed ones though, the bitmaps are actually smaller for some reason.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by anasiqbal · Apr 08, 2016 at 07:15 AM

Hi, I know its quite late to reply but incase if anyone else is looking.

  1. Yes, these textures are Unity's textures (some used by the editor).

  2. You can get a better idea of your memory usage by filtering out the textures using texture.hideFlags. (source code attached)

      int totalTextureMemorySize = 0;
      HideFlags hideFlagMask = HideFlags.HideInInspector | HideFlags.HideAndDontSave;
      HideFlags hideFlagMask1 = HideFlags.DontSaveInEditor | HideFlags.HideInHierarchy | HideFlags.NotEditable | HideFlags.DontUnloadUnusedAsset;
     
      var textures = Resources.FindObjectsOfTypeAll(typeof(Texture));
      foreach(Texture t in textures)
      {
          if (t.hideFlags == HideFlags.HideAndDontSave || t.hideFlags == hideFlagMask || t.hideFlags == hideFlagMask1)
             continue;
     
          textureCount++;
          int memoryUsed = Profiler.GetRuntimeMemorySize(t);
          Debug.Log("Texture: " + t.name + " : hideFlags: " + t.hideFlags.ToString() + ": Memory: " + (memoryUsed/1000000f));
     
          totalTextureMemorySize += memoryUsed;
      }
    
    

Resources.FindObjectsOfTypeAll helps you find all the textures loaded into the scene. The if statement helps filter out unity textures, and Debug.Log gives you information about the textures and their hideFlags.

You can comment the if statement temporarily to see what textures being loaded by unity and their hideFlags.

NOTE: Profiler.GetRuntimeMemorySize works in the editor and development builds but not in release builds. And this function is very slow, therefore, it is not recommended to run it every frame. For more information see here and here.

Also, looking at the logs generated by above code You will figure out that when textures are loaded into the scene there sizes are increased. By my experience a 0.5mb PVRTC compressed image when loaded into the scene takes almost 4 mbs of memory (if your looking in the editor). But if you check this on a device (I checked on iPhone4s) the size will be doubled i.e. 1 mb for a 0.5mb PVRTC compressed texture. I don't know why does this happens (still doing some research) but if any on knows why please let everyone know. But at least you will get the idea how much memory is being used by your textures inside a scene.

@awall: Hope you will find some trust in the profiler.

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 stevesan · Nov 14, 2013 at 04:51 AM

Interestingly, the "memory" graph part of the profiler typically shows a lower level than the text status. I guess the text includes the total reserved size, not actually used?

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 Rs · Jan 13, 2015 at 02:23 PM 0
Share

Please move to comments

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

17 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

Related Questions

Textures/Atlases and memory management 0 Answers

Why are compressed textures showing up huge in memory? 0 Answers

TEXTURE has wrong size in memory 1 Answer

Changing textures accumulate in memory. iOS. 0 Answers

Object references listed in profiler but not in hierarchy. 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