I have created a Blackjack app for the iPhone. It takes up 70 MB of memory when it runs. Is this too high? It seems a bit high to me. Or is this normal considering I'm using some graphics/animation (for cards, chips etc.)
-
1You should be fine... http://stackoverflow.com/questions/21071311/how-much-memory-can-one-ios-app-use – PCoder123 Apr 15 '14 at 21:14
-
thanks for your response! I was also wondering in general if I am using more memory than necessary given the type of app it is? I am curious if my coding has been wildly inefficient from a memory usage standpoint. Any idea if this is on the high end for an app of this type? thanks. – mattman88 Apr 15 '14 at 21:31
-
When you say you're using animation, do you mean lots of graphical resources or do you just mean CoreAnimation for on-GPU work? – Tommy Apr 15 '14 at 21:43
-
3It's tough to say without seeing the implementation. Have you run the app using instruments? It will show you what operations in the code are taking up the most memory. If you are not familiar with instruments I would definitely recommend brushing through this tutorial at least just to see the types of features it offers. http://www.raywenderlich.com/23037/how-to-use-instruments-in-xcode – PCoder123 Apr 15 '14 at 21:47
-
1@Tommy I am just using CoreAnimations. Specifically the method animateWithDuration:delay:options:animations:completion. – mattman88 Apr 16 '14 at 01:15
-
1@PCoder123 I will read that tutorial right now. Thanks very much for your advice. It is MUCH appreciated – mattman88 Apr 16 '14 at 01:16
2 Answers
Less demanding games than yours, like Tic Tac Toe, take around 10 MB. However, yours has animation. I'm assuming it is 2D animation, since 3D games take around 500 MB, and fancier ones near 1 GB.
Without looking at what the code is doing, it seems to be within the accepted range for a nice 2D Blackjack app.
That being said, it wouldn't hurt to look at Apple's advice for lowering an app's memory usage.

- 320
- 3
- 9
-
Awesome, thank you very much! Yes just 2D animation. I'll take a look at that page you suggested for sure! – mattman88 Apr 16 '14 at 01:18
Observation: using less memory just for the sake of it is of no advantage. How is having 500mb of unused RAM better than having 450mb?
As a result of that observation, a common mechanism used in iOS is NSCache
. It's [approximately] an associative map that will keep things about unless or until doing so causes undue memory pressure. That same pattern is used more generally. Use what's available unless or until doing so causes somebody else a problem. That's why low memory warnings exist. Such caches are used by both developers and by the system — e.g. for every call to [UIImage imageNamed:]
.
So beyond that it depends on your assets, how your views are arranged and a bunch of other factors.
A retina iPhone 5S has a resolution of 1136x640 pixels. So that's about 2.8mb of data. You mention animations: do you have sufficiently many different assets to add up to 25 screens of animation? If so then that's 70mb.
What about your views? Are you keeping lots of independent views about? Each view has a CALayer
which under normal circumstances means a GPU footprint. As with NSCache
, such memory is kept unless memory pressure indicates a need to do otherwise (and even then anything that is part of the current hierarchy has to keep its storage).

- 99,986
- 12
- 185
- 204
-
3Wow, your 2.8mb of data thing was pretty much spot on, I just tested it again and I have about 30 screens of animation and my app is taking up about 80mb of ram. love learning new things. thanks! – mattman88 Apr 16 '14 at 01:25