Ian Turner
Ian Turner

Reputation: 1413

Cocoa application appears to crash when the main window is closed

My application seems to have acquired a slightly odd behaviour when it terminates. When I close a the main window using the standard little red button in the top left the application crashes. I haven't made any changes to the application that would obviously cause this problem. I'm struggling to debug the problem because the application crashes and my debugging skills are limited. Does anyone know any obvious reason why this might occur or a debugging strategy that I might be able to adopt?

Upvotes: 0

Views: 1001

Answers (3)

kompozer
kompozer

Reputation: 2094

I would also say it must be some kind of memory leak. You mention that your debugging skills are limited, but it is actually quite easy do debug those with the new Instruments app. Here is a very nice article about it.

Upvotes: 0

zorn
zorn

Reputation:

One new option in IB 3 is a setting for NSWindows to release when closed. Make sure you have that checked off and/or are retaining the window properly/

Upvotes: 0

Joel Levin
Joel Levin

Reputation: 2898

If it crashes with EXC_BAD_ACCESS (which sounds likely, although may not be the case - you didn't specify), it is likely something to do with one of your dealloc methods somewhere. The app dealloc's everything right before quitting, so make sure you aren't releasing something that has been autoreleased, for example.

If you are comfortable using GDB, I would try setting breakpoints maybe in something dealloc methods and just see what state the stuff you're releasing may be in.

Crashes like these can be tricky to debug without doing some exploration first to find out what is actually causing the problem.

Upvotes: 3

Related Questions