开发者

Object allocation and memory warning

i have an application which takes "live bytes" up to 3mb. The 开发者_开发技巧application showing memory warnings and it will crash continously. when i use object allocation tool i can see the live bytes.im using imageWithContentsOfFile in many places. i can see NSConcreteData object is taking more momory.what is the reson for that? may i know how much memory is allowed to an application.


You can't really know how much memory you're allowed to use, but in general you're fine up to 20mb on iPhone/iPod devices. However, your app can be killed not only for using too much memory, but for failing to decrease memory usage when warnings are issued. So even if you're not using all that much memory, if the system detects that you don't release any memory when getting memory warnings, your app might be shut down. At least that's my experience, maybe others have more detailed knowledge about what's going on.

imageWithContentsOfFile: has a built-in caching mechanism, so if you're loading the same images over and over, there should be very little overhead.

EDIT: imageWithContentsOfFile: does not cache images. The method imageNames: does cache images, and it's the only image creation method that does.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜