Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
511 views
in Technique[技术] by (71.8m points)

objective c - How much memory can an iPhone app use?

Can anyone link me to a page that describes memory allocations for iPhone apps.

I have heard that you are limited to a sandbox of ~20 megs, depending on the state of the phone, but I can't find the source for this.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It depends on the device you're using. I've found that with an iPhone 3G, when the total memory your app is using goes over 10-14MB, it's vulnerable to crashing. When it hits 20MB, it will crash for sure.

As far as I know, Apple doesn't give any hard figures for the memory that you can use. It's always changing so it's hard to pin down. They recommend that you rely on memory warnings and respond to them appropriately.

iPhone 3GS has a much higher amount of memory available to apps (I've heard that it's around 4 times). Although the iPhone 3GS only has double the memory of the iPhone 3G, a lot of that memory is taken up by the OS. There's very little left for apps to run in. That's why the 3GS will allow apps to use so much more memory.

Also, there can be a lot of memory already in use by the OS. One example is when safari is keeping a lot of tabs open. This is why lots of games recommend that you restart the device if it crashes a lot.

When you're programming, keep an eye on the increase of memory (due to not properly deallocating objects) and the peak memory. This problem is more about real-world testing (on as many devices as possible) and good programming practices.

Here's an article to ready more about how to deal with memory problems:

http://akosma.com/2009/01/28/10-iphone-memory-management-tips/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...