• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: resetting ivars safely
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: resetting ivars safely
      • From: Chris Suter <email@hidden>
References: 
 >resetting ivars safely (From: Daniel Child <email@hidden>)

  • Prev by Date: Re: resetting ivars safely
  • Next by Date: DVD name via Cocoa?
  • Previous by thread: Re: resetting ivars safely
  • Next by thread: Re: resetting ivars safely
  • Index(es):
    • Date
    • Thread