I have an application that uses a couple UIViewControllers
with SKScenes
inside, some large images and ObjectAL for sounds.
After pushing a couple view controllers with SKScenes
inside (and yes, I know this is not inline with SpriteKit best practices), my app gets to around 120 MB of RAM. At this point, I receive some memory warnings and the background images in my SKScenes
get released. This is surprising because the iPad 3 I'm working with should crash at 624 MB, and 120 MB is much less than that (source).
The strange thing is that as I run my app, the amount of RAM used by Other Processes dramatically increases. Check out the following video along with my notes over time: https://www.youtube.com/watch?v=GoMKK3XXWFw&feature=youtu.be
- At 0:00, the app has just launched. It's on a menu screen which uses 6.9 MB of memory. Other processes are using up 235 MB of memory.
- At 0:10, I open the game itself. It loads a bunch of images, going up to 80 MB. Strangely though, other processes are now using 300 MB of memory. Why the 70 MB jump?
- At 0:20, I go to the next screen in my app, which increases the memory by 5 MB (up to 85 MB). Other processes jump to 340 MB (+40 MB).
- At 0:33, I go to the next screen in my app. My app's memory use stays around 85 MB, but the other processes jump to 400 MB (+60 MB).
- At 0:40, I go the next screen in my app. My app's memory goes up to 90 MB, but the other processes jump to 440 MB (+40 MB).
- At 1:00, I trigger an animation which loads a couple new images. My app's memory briefly goes up to 115 MB then drops back to 95 MB. Other processes' memory doesn't change.
- From 1:00 - 1:40, I'm playing through a screen, loading sounds along the way up to 105 MB. At 1:40, I load a new image, jumping up to 120 MB. Other processes' memory is essentially constant throughout.
- At 1:45, I load a new screen and again other processes' memory jumps to 500 MB.
- Around this point I'll get a memory warning and my background images will be released. It makes sense because I'm using 120 MB (my app) + 500 MB (other processes) = 620 MB.
I'm not sure exactly how to debug this. I've tried to look at my memory use in the Instruments' tool Activity Monitor, but it doesn't record the large other process memory jumps.
Two questions:
1. Why is this occurring?
2. How can I debug something like this?
UPDATE
The Other Processes memory consumption pattern is very different across devices. The memory usage patterns below are per screen (per ViewController push). iPad Mini: 233 MB —> 170 MB —> 160 MB —> 155 MB —> 160 MB —> 155 MB —> 105 MB iPad 3: 320 MB —> 380 MB —> 400 MB —> 440 MB —> 470 MB —> 470 MB —> 370 MB