开发者

What is the comfortable range for Live Bytes(memory allocation) in an iphone app

开发者 https://www.devze.com 2023-01-08 03:14 出处:网络
What is the开发者_StackOverflow中文版 comfortable range for a running iphone app. My app currently peaks around 5.4 mb and would like to know the correct amount which causes crashes.

What is the开发者_StackOverflow中文版 comfortable range for a running iphone app.

My app currently peaks around 5.4 mb and would like to know the correct amount which causes crashes.

I have heard that on the iphone 3G there is around 40 mb minus the running apps such as Mail, Safari etc.

Does anyone know the truth around this?


An Apple engineer told me roughly 25 megs on the 3G and 50 megs on the 3GS are available for an app. I've tested this and seen roughly the same numbers before my app was killed. Don't know details now though, with background apps, or on the iPhone 4.


Backgrounded apps can be killed on a memory warning to give the foreground app more memory, so the whole concept of "memory usage" and "free memory" is somewhat useless. If you watch the app/console log and don't see any memory warnings, then stop worrying. "Level 1" memory warnings aren't surprising if you're doing anything vaguely memory-heavy (taking pictures, AVCapture, image processing). "Level 2" memory warnings mean you should be a bit careful, and "level 3" is the last one before your app gets killed IIRC.

Test on the worst device your app supports, e.g. the original iPhone/iPod Touch running 3.1.3 or the iPhone 3G/iPod Touch 2G on 4.0.1 if you don't support 3.1. Testing on an old device also reveals performance issues, especially where graphics hardware is involved — CALayer.mask, CALayer.contentCenter, and UIView.contentStretch are only properly supported on the 3GS and above (iPhone 4, iPad, presumably iPodTouch 3G), and either render a bit odd or sluggishly on older devices. It's up to you to decide what's "acceptable" performance for older devices.

It's not usually worth testing on old OSes for memory/performance reasons (there was a syslogd memory leak in 2.something, but you can assume that most users have upgraded). Note that newer OSes are often slower — 4.0 is much slower than 3.1.3 on a 3G, but performs perfectly well on a 3GS. Perhaps it's ARM vs. Thumb, or just planned obsolescence, but it's worth knowing about.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号