Quantcast
Channel: Questions in topic: "issue"
Viewing all articles
Browse latest Browse all 827

Sprite Atlas is loading multiple times in the memory

$
0
0
- 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][1]

- 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][2] [2]: /storage/temp/133372-sprite-atlas-settings.png [1]: /storage/temp/133373-unity-profiler.png

Viewing all articles
Browse latest Browse all 827

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>