I have developed one iPhone application with Snow Leopard (10.6.2) and
Xcode (3.2.1). As many of us know that in this new version of Xcode we
get facility of Build and Analyze (to check memory leaks and other
issues). When I build and analyze my application, it gives me no
error / no warnings.
My application runs fine on simulator also.
Now, I try to test the application on iPhone device (device
configuration: iPhone 2G and iPhone OS 3.0) with 8GB memory.
The problem is that application starts well on iPhone device but after
some time, it crashes.
When I see the console from Window->Organizer->Console. I see
following error:
Tue Dec 22 17:17:39 unknown SpringBoard[27] : Memory level is urgent
(8%) and there are no background apps to ask to exit.
Please help me.
Regards, Pratik
memory situations on the 'simulator' are different than the native device - dramatically different! so, this is something you should expect to test for on a device.
perhaps you need to bound a long running loop in an autorelease pool?
sometimes a loop can generate a lot of objects which are not released until the thread returns to the main loop and in such cases, you can let go of that memory on the fly by using an nsautoreleasepool and releasing it during the loop.
that would not be a leak, but would be a situation where you use up too much memory at once on the device.
Run > Start With Performance Tool > Leaks
or
Run > Start With Performance Tool > ObjectAllocation
will quickly show what you're leaking and where it was allocated.
An 8GB iPhone has about 12M for your app. It's very easy to leak a few
large images and have no room left.