On 28 mars 2011, at 20:31, Fritz Anderson wrote:
On 28 Mar 2011, at 9:59 AM, Jean-Denis Muys wrote:
- the crash happens when stepping over this code line: [self drawInRect:destRect]; where
"self" is a UIImage
- the app display all go away, showing the springboard.
- the Xcode button is still enabled, suggesting that my app is still running.
- the debugger console doesn't report anything *at all*: no error, no exception, nothing
- the debug navigator is empty and only shows "Process Running"
- the pause/continue button is in its "continue" state (right pointing arrow), just as it was before stepping over. pressing it does nothing
- pressing my app icon on the device's multitasking bar restarts it from scratch.
- pressing Xcode's stop button seems to kill the app, but without any additional output in the debugger console
The code is from a small category I wrote on UIImage to draw thumbnails for images. It's quite straightforward and shown entirely below.
My suspicion is that this problem is memory related, as the image I am trying to scale down here is 6622x9361 pixels in a 6 MB JPEG file.
Um, yeah. That image would require about 248 million bytes to render in memory; JPEGs are compressed when they're files, but to work with them, they have to be rendered into big bad bitmaps. 248M is (to understate) a large chunk of the RAM on most
devices.
If you run yourself out of memory, you will be evicted. No warning (if you do it all at once), no console message, you're dead. Apparently Xcode 4 doesn't catch up to the death of the process, and the debugging session has to be stopped manually.
You don't see it in the Simulator because the Simulator, and the apps it runs, are Mac OS X applications. They have access to many times the RAM your device has, backed with a swapping virtual memory system. You can't (unless you try) run a simulated app
out of memory.
In the Device Organizer, select the "Device Logs" item for your test device. A crash log for your app will appear in the listing, but all it's going to tell you is that you ran out of memory. You know that.
No crash log for the device. This is weird. However, if look at the "Device console" when doing it, I get indeed console warning about memory being low, with the eventual notice that my app has been killed:
Wed Mar 30 11:50:43 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.cmd-informatique.surveyor[0x17ae]) Exited: Killed
Wed Mar 30 11:50:43 unknown SpringBoard[2223] <Warning>: Application 'Surveyor' exited abnormally with signal 9: Killed
Wed Mar 30 11:50:43 unknown ReportCrash[12368] <Error>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2011-03-30-115043.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0
But contrary to that last line, a crash report is not saved.
Run your app under Instruments, with the Allocations template. Adjust the VM instrument to sample every second or so instead of manually. Run your app, and look particularly at the "dirty" memory, which is the actual burden on RAM. That will give you a
clue to what's eating up memory.
When I trigger the "crash" on the device, Instruments beachballs. I will try on another Mac.
But you already know: You're trying to fill a quarter-gigabyte of RAM on a non-swapping machine that doesn't have that much memory to spare.
— F
Yeah of course I know. The near impossibility to confirm that through debugging tools is puzzling though.
JD
|