0

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

  1. 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.
  2. 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?
  3. 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).
  4. 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).
  5. 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).
  6. 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.
  7. 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.
  8. At 1:45, I load a new screen and again other processes' memory jumps to 500 MB.
  9. 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

Community
  • 1
  • 1
rizzes
  • 1,532
  • 20
  • 33
  • How are you loading these images? – Tom Harrington Dec 11 '14 at 21:22
  • `[SKSpriteNode spriteNodeWithImageNamed:]`. Sometimes with through an atlas -- `[atlas textureNamed:]`. – rizzes Dec 11 '14 at 22:03
  • i think you are skipping some core concept of preloading texture's atlas first never use [SKSpriteNode spriteNodeWithImageNamed:] use [atlas textureNamed:] and save them as a singleton object or in a NSMutableDictionary for further use secondly load them from Load textures from largest to smallest for more information just check this nice article written by Steffen Itterheim http://www.learn-cocos2d.com/2012/11/optimize-memory-usage-bundle-size-cocos2d-app/ – dragoneye Dec 12 '14 at 05:08
  • have you tried rebooting the device? – CodeSmile Dec 12 '14 at 10:03
  • @LearnCocos2D I have tried rebooting the device and I get the same RAM progression. One extra point of data: When I finish the view controller progression and return to the menu screen (calling `[[self presentingViewController dismissViewControllerAnimated:NO completion:NULL]; and [self setViewControllers:[NSArray new] animated:NO];` from a `UINavigationController`), the "other processes" RAM DROPS significantly (100+ MB). – rizzes Dec 12 '14 at 18:59
  • @dragoneye I need to use `[SKSpriteNode spriteNodeWithImageNamed` because some of my images don't fit into an atlas. Although I also LOVE that article, I'm not sure if it affects this current issue. Why would saving the textures in a singleton object/loading them from large to small affect the "other processes" memory usage? – rizzes Dec 12 '14 at 19:03
  • hi rizzes for other progress did you tried Instruments->activity moniter you can get exact information which process in other process stack getting that much memory secondly why don't you break your big images into small pieces and combine using a texture atlas – dragoneye Dec 13 '14 at 05:29

0 Answers0