Re: resetting ivars safely
Re: resetting ivars safely
- Subject: Re: resetting ivars safely
- From: Chris Suter <email@hidden>
- Date: Thu, 13 Sep 2007 08:27:05 +1000
On 13/09/2007, at 6:59 AM, Daniel Child wrote:
HI All,
I am trying to find a way to safely reset or reinitialize the
instance variables of a singleton object. A "word parser" behaves
correctly the first couple of times it is used, but then self-
destructs. Everything goes fine the first time through, but on the
second or third attempt to reset the wordCandidates ivar, an EXC-
BAD-ACCESS signal is generated just prior to releasing the ivar in
its setter (using the release, then copy paradigm). Since the
retain count prior to releasing is 1, I am mystified.
I suspect that you've probably got some memory management issues ---
some extra releases somewhere else. You're missing some release/
autorelease messages in your init method which don't look like the
cause of the problem but suggest it's worth you having another look
at the memory management documentation.
I wouldn't read too much into the fact that the retain count is
reported as 1 since the objective C implementation doesn't store the
retain count with the object. It stores the retain count in a global
hash if it's more than 1. The absence of the object in the hash means
it will cause it to report 1 but that could be because your object
has been deallocated. I'd turn on zombies and see what happens. It's
possible that the problem lies with your singleton having been over-
released.
- Chris
_______________________________________________
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