When, I run my application 开发者_Python百科in the simulator using the Leaks instrument, it uses about 2.5mb of memory. When I run it on the iPhone, it takes forever to launch, slowly climbs to ~34mb of memory and then crashes. However, when I run it on the iPhone without Leaks, it launches quickly and runs fine. Why is this?
Do you have zombie detection enabled?
Zombie detection will cause every object allocated to never be deallocated (the object is marked as a zombie on deallocation). This will cause memory growth as you describe. A common mistake is to leave zombie detection enabled when using Instruments, either through environment variables or through the checkbox in the Object Alloc instrument.
If it isn't zombies or leaks, then it is -- as others have said -- memory being allocated and sticking around. Use the Object Alloc instrument to track the objects allocated in your application and make sure that every single one of them exists for a reason. You can turn on "only track live allocations" to filter out all the objects that have already been deallocated.
The crashes are probably due to the memory leaks you have in your app and the device running out of memory. Without seeing any code it is impossible to tell. Here is a tutorial on how to use instruments
The "takes forever to launch" and and runs slowly is due to the leaks monitoring system polling the device every 10 seconds for information
EDIT: It is probably due to keeping too many objects alive in memory at a given time. Check instruments and Object Allocations. Just because you have no leaks doesnt mean you can't run out of memory
精彩评论