• 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 DaJuice · Mar 01, 2013 at 02:14 PM · iostexturememoryprofileratlas

Textures/Atlases and memory management

I've been making a game for 5 months now, following what the profiler tells me, but I've been told that the unity profiler is kind of unaccurate, but I never thought it would be so much.

I've just started using Instruments for iOS andI've discovered that (on iOS at least) the profiler is completely irrelevant, or that I'm doing something very wrong, I'm asking you this to make sure I'm not doing something wrong.

The game we're making is really texture heavy (we have over 30 jam packed atlases, most of 'em 1024x1024), at the title screen, the unity profiler tells me it uses about 20MB, the Instruments profiler tells me 90MB. What I understand from that, is that the unity profiler hides the textures that are currently used but not on screen from the memory profiler.

This means that the unity profiler tells me that only the title screen is in memory and my other textures are somehow compressed, ready to be used, but in fact my whole UI is loaded with all it's textures fully uncompressed.

Now that is some hope of not having to heavily manage those textures gone, but I'm telling myself that there must be a reason why the profiler tells me that they are automatically managed?

So is there some magic incantation to make in order to make this automatic textures management work, or do I have to manually manage those?

Comment
Add comment · Show 5
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 mgoi.tbgames · Mar 01, 2013 at 04:14 PM 0
Share

The answer is: It depends.

How are you loading the textures? AssetBundles, WWW class (no AssetBundles), Resource directory or are they part of a scene?

avatar image DaJuice · Mar 01, 2013 at 04:15 PM 0
Share

For this situation, they are part of the scene

avatar image mgoi.tbgames · Mar 01, 2013 at 04:22 PM 0
Share

I guess this is the reason you require that much memory. Unity loads the complete scene to memory. If you want to prevent this you have to load the assets on the fly.

Put them in a folder and load them via WWW class or the Resource class. $$anonymous$$eep in mind that you have to dispose textures manually if they are no more needed (Object.Destroy()) otherwise the memory is not released.

Sometimes it helps to call Resources.UnloadUnusedAssets to free the memory.

avatar image DaJuice · Mar 01, 2013 at 04:31 PM 0
Share

Thanks for confirming this, it is just that I feel betrayed by the unity profiler who told me that even when I have many atlases used in my scene, only the ones I currently see are "uncompressed" or use space in RA$$anonymous$$, so there is really no trouble in not managing memory, but I guess I'll have to rethink my strategy.

avatar image mgoi.tbgames · Mar 02, 2013 at 08:23 PM 0
Share

You're welcome. In the last years I also had to learn that you should never rely only on the profiler or the memory functions unity offers. $$anonymous$$any memory issues are just not covered.

Some tipps on memory usage:

  • Always have a task manager or other memory tool running

  • Write code in an unmanged style (clean up your instances properly, null object, remove event handlers, ...)

  • Restart the editor if you think some memory corruption occured

  • Free static objects on you own or they might remain in memory when loading an other scene or leave the play mode

  • Do not load to many resources at the same time to prevent fragmentation

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

10 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

Related Questions

Determining Texture Memory Usage 2 Answers

Changing textures accumulate in memory. iOS. 0 Answers

Loading external Image as Texture2D increases memory consumption dramatically on iOS 0 Answers

Memory usage for the simplest iOS/Android app grows over time, says Unity 3.5 Profiler 0 Answers

single texture atlas or multiple textures? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges