Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much memory should my iPhone app be taking up?

Tags:

memory

ios

iphone

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.)

like image 350
mattman88 Avatar asked Apr 15 '14 21:04

mattman88


2 Answers

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).

like image 161
Tommy Avatar answered Sep 30 '22 20:09

Tommy


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.

like image 39
Java Riser Avatar answered Sep 30 '22 18:09

Java Riser