Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 ComaneanuMugurel · Feb 19, 2019 at 09:21 AM · spriteissuememory management

Sprite Atlas is loading multiple times in the memory

  • I'm having this problem where my sprite altases are being loaded into memory multiple times. This causes unnecessary memory usage and, on some of my devices that run android 6.0 with 1GB of ram, the app crashes. Mind you that i have some android devices with android 6.0 and 1GB that can run the app just fine, but i still have the same issue, very large memory consumption.

  • I tried profilling with the android studio profiller and with unity build-in profiler and the memory usage reported was the same. alt text

  • The app that i am developing is using ~1000 sprites, so it makes sense to use sprite atlas, both for build size and memory consumption.

  • The app crashes right between two scenes, i am using Async load, and at it's peak the memory usage reaches 0.53gb, which in my opinion for a small android build seems insane, right after that the app crashes on that device.

  • The method i am using for loading the sprite altases is with SpriteAtlas.GetSprites(), than i am storing the sprite in a static array, and i am making sure that SpriteAtlas.GetSprites() is never going to be called during the current game session. This, in my mind, removes any connection between sprite atlas and it's contents. I am using this approach because i've seen that pulling sprite by sprite, using the SpriteAtlas.GetSprite() method, can be quite CPU and memory intensive in comparison with my current method.

  • Unfortunatley the unity documentation does not give any warning for bad practices so in this case i am unsure if am missing something in my programming, and it gets quite frustrating not knowing how should i approach this problem. Also i've seen that many other developers have this issue, but most of them have this problem in editor, where the profilling data is not coherent when it comes to a fizical device build.


  • This is really important since i will be publishing more games with the same theme, and i need to improve my tehnique in order for my apps to perform at their best both on high-end devices and low-end.


  • If there are any questions, about the code i used or about how the sprite altases are packed, i am more that happy to resolve this problem, not just for me but for any other developer that may come across this problem. alt text

sprite-atlas-settings.png (99.0 kB)
unity-profiler.png (27.9 kB)
Comment
Add comment · Show 2
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 zereda-games · Feb 19, 2019 at 12:05 PM 1
Share

Don't have a solution to this problem, apologies, so i'm not posting an answer. I'll be having difficulties in this area co$$anonymous$$g up here soon I'm sure, because i did sorta learn something from this post, haven't looked into Sprite Atlas's yet and by this post, sounds like the route I'll need to take over what i was doing. Glad i read this and will be fav'ing it for further future references. Thanks for posting.

PS.

Whats your take on object pooling for this sort of instance? or is this a premade class for dealing such an aspect?

avatar image ComaneanuMugurel zereda-games · Feb 19, 2019 at 12:23 PM 0
Share

I am storing the sprites that i know i am going to use them in all scenes in a static array. This way there will not be any hiccups when i will try to fetch any of them.
- Update I found out why the sprite atlases are being loaded multiple times on the build. The reason for that is because some of the sprite altases have more than 1 "packs". For example if i try to pack 48 sprites into a 2048x2048 atlas, and they won't all fit in the atlas, unity will create 2, 3, 4 etc, to fit them all. I guess this is the answer. But unfortunatley this does not solve my problem, the app still crashes, and i am looking for some other reason why is crashing. I will keep you up to date if i found something usefull :)

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by ComaneanuMugurel · Feb 19, 2019 at 04:29 PM

This was a something that i overlooked and for some of you that may come across this problem, this is completely normal. The reason behing the atlas being loaded multiple times, is that each atlas has a number of "pages", and each of that page is being loaded into memory. There is no unecessary memory usage. Hope this helped some of you understand what happens, and is a bit sad that i had to find this out by testing not from the documenation.

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 MartinTilo · Aug 23, 2019 at 06:17 PM 0
Share

Thank you for the feedback, I've made a note to add it to the documentation. Also, I'll look if we can't improve upon the UX for this in the new $$anonymous$$emory Profiler Package.

If anybody else encounters similar issues and it's not due to paging: it could also be due to there being multiple versions of the atlas, stem$$anonymous$$g from different asset bundles. Or if you profile the Editor, the editor retains a copy of the atlas on the CPU for read/write access.

avatar image fablelabs · Jul 24, 2020 at 10:19 PM 0
Share

How did you deter$$anonymous$$e that these were pages? I think we have the same issues. I'd like to confirm that it is paging for us too.

avatar image
0

Answer by HofiOne · Jan 13 at 01:46 PM

just for the record, nowadays unity also prefixes the pages indexed, like

sactx-01- sactx-02- sactx-03- etc.

(also you can see in the references count column different values that suggests those objects are not the same)

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

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

133 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 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 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 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 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 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 avatar image

Related Questions

Splitting a huge sprite and memory management? 1 Answer

Unity5 sprite.create perfomance issue in editor? 0 Answers

weird looking images 2 Answers

Sprites are being cut in half. HELP! 4 Answers

2d game sprite frame of object issue 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