Re: Breaking on runtime asserts
Re: Breaking on runtime asserts
- Subject: Re: Breaking on runtime asserts
- From: Andy Lee <email@hidden>
- Date: Sat, 27 Jul 2002 22:23:28 -0400
At 3:01 PM -0700 7/27/02, John Scalo wrote:
I am getting random runtime messages like
2002-07-27 14:55:39.651 MyProgram[5006] *** -[NSImage count]: selector not
recognized
This looks like an excellent candidate for a retain bug. You may
have neglected to retain an object. The object then got released
even though you still had a variable pointing to it, and a new object
that you created later reused the first object's memory. So now you
had a variable pointing to an NSImage when youre code expected it to
be pointing to something else.
However I have no idea where why or when this is happening. Is there an
option (maybe a gdb option?) I can set to break when these runtime asserts
occur?
At 12:14 AM +0200 7/28/02, David Remahl wrote:
Break on [NSException raise]:
(gdb) break -[NSException raise]
Yup, this should help. At the point where the exception is raised,
look at the object that is receiving the -count message. You
probably declared it to be an NSArray or something similar, but it
got written over by an NSImage. That's the object you need to add a
-retain call to. See the docs on memory management, in particular
retain/release, in your /Developer/Documentation directory.
Understanding retain/release is very important.
--Andy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.