• 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: Class hierarchy weirdness.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Class hierarchy weirdness.


  • Subject: Re: Class hierarchy weirdness.
  • From: Marcel Weiher <email@hidden>
  • Date: Thu, 18 Apr 2002 11:43:53 +0200

On Thursday, April 18, 2002, at 11:27 Uhr, Kigney wrote:

In my program, I have a class hierarchy looks like
this, from top to bottom:

NSObject
MyObject
Character

When [characterInstance dealloc] is called, though,
something _very_ strange happens. Here's my best
attempt to diagram it as a stack. Note: all of the
methods below call [super dealloc] at the end of their
own dealloc methods.

[characterInstance dealloc]
[myObjectInstance dealloc]
[characterInstance dealloc]
[myObjectInstance dealloc]
Signal 11, or signal 10. The program
quits.(Probably because it's trying to re-deallocate
myObjectInstance's data members.)

This can happen if you have a cycle pointing back to yourself somewhere in your pointer structure, meaning that the problem would be in the object structure, not in the class structure as you suspect. Of course, I am guessing wildly here and so could be completely wrong.

The way that happens is that your dealloc releases some objects, which dealloc themselves, which then release your object. This will trigger the dealloc again despite the fact that you're already deallocing yourself.

To get to this point, you must have broken the retain cycle somehow, which would otherwise cause the whole cycle to simply leak and dealloc never to be called in the first place.

I bumped into this when I implemented a small garbage collector to clean up some structures where retain-cycles could not be avoided a-priori. Took me a while to figure out, too.

Marcel


--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
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.

References: 
 >Class hierarchy weirdness. (From: Kigney <email@hidden>)

  • Prev by Date: Re: NSTime controller
  • Next by Date: Re: Class hierarchy weirdness.
  • Previous by thread: Class hierarchy weirdness.
  • Next by thread: Re: Class hierarchy weirdness.
  • Index(es):
    • Date
    • Thread