EXC_BAD_ACCESS in a Core Data application
EXC_BAD_ACCESS in a Core Data application
- Subject: EXC_BAD_ACCESS in a Core Data application
- From: Ian Piper <email@hidden>
- Date: Fri, 04 Sep 2009 17:35:12 +0100
Hi all,
I have been putting together a Core Data application that has three
windows. I wanted to control the appearance and disappearance of these
windows during the course of the application, so added menu items and
buttons with the action makeKeyAndOrderFront. However, I found that
the program hung while running: specifically while re-opening a window
that I had previously closed. The GDB message was 'Program received
signal: “EXC_BAD_ACCESS”.' I couldn't get very far with this: Tech
Q&A 1367 said that it was probably the result of over-releasing an
object. I couldn't see how that had happened, since I had really just
gone with the code generated by Xcode: so I wasn't knowlingly
releasing anything that I could see. However, after a bit more digging
I realised that the problem was in IB: in the Window attributes I
noticed that the Behaviour option "Release When Closed" was checked.
When I unchecked this option the application ran fine - no hang.
I suppose that when I close the window it is released, so when I try
to open it again there is nothing to open.
My questions are:
1. Why does a window default to having this option checked? It seems
odd, since the auto-generated code seems to look after memory
management and therefore this is more or less guaranteeing a problem.
2. What is the best strategy for tracking down this kind of problem? I
tried using Instruments and that indeed showed a memory leak at the
point that I tried to load this window, but I couldn't see how to use
this information to zero in on the root cause.
3. Is there a way to attach a breakpoint to a UI action (such as
clicking on the File menu, which is where the freeze happened)?
4. Without wishing to open any cans of worms, a Core Data application
like this seems like a sensible place to use GC. Is that right?
Any illumination will be joyfully received.
Ian.
--
email@hidden
07590 685840 | 01926 811383
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden