• 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
Zombie object being messaged - why?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Zombie object being messaged - why?


  • Subject: Zombie object being messaged - why?
  • From: Martin Hewitson <email@hidden>
  • Date: Fri, 25 Jan 2013 16:52:57 +0100

Dear list,

In a document based app running under ARC, I've been struggling for an eternity to get to the bottom of an occasional crash which happens when closing a document. I've spent a huge amount of time working on my -tearDown procedure which I call in my NSDocument subclass' -windowWillClose: and which subsequently calls -tearDown on many other app components. I also hit the same crash:

[MHControlsTabBarController performSelector:withObject:]: message sent to deallocated instance 0x1075d2cb0

MHControlsTabBarController is a view controller whose view is added to the document's main window when the document loads.

In my document's -tearDown I do:

  // clean up tab bar controls
  [self.controlsTabBarController tearDown];
  self.controlsTabBarController = nil;

In [MHControlsTabBarController tearDown] I nil out various state variables. I've also tried various things in that -tearDown, like removing the view controller's view from the superview, cancelling any run loop performs by doing:

  [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget:self];
  [[NSRunLoop mainRunLoop] cancelPerformSelectorsWithTarget:self];

nilling out all IBOutlets, etc, but nothing helps so far.

I ran the app under instruments and I get a nice zombie message when closing the document. The object history is long, but the last few entries are:

#	Address	Category	Event Type	RefCt	Timestamp	Size	Responsible Library	Responsible Caller
2111	0x10a395410	MHControlsTabBarController	Retain	2	03:29.823.791	0	TeXnicle	-[TeXProjectDocument controlsTabBarController]
2112	0x10a395410	MHControlsTabBarController	Autorelease	 	03:29.823.792	0	TeXnicle	-[TeXProjectDocument controlsTabBarController]
2113	0x10a395410	MHControlsTabBarController	Retain	3	03:29.823.792	0	TeXnicle	-[TeXProjectDocument tearDown]
2114	0x10a395410	MHControlsTabBarController	Release	2	03:29.825.781	0	TeXnicle	-[TeXProjectDocument tearDown]
2115	0x10a395410	MHControlsTabBarController	Release	1	03:29.825.784	0	TeXnicle	-[TeXProjectDocument setControlsTabBarController:]
2116	0x10a395410	MHControlsTabBarController	Release	0	03:29.877.132	0	Foundation	-[NSAutoreleasePool drain]
2117	0x10a395410	MHControlsTabBarController	Zombie	-1	03:31.405.789	0	AppKit	-[NSWindow sendEvent:]

Should I interpret this as a window trying to message the object?  Am I somehow over-reasling? Under ARC, I can't, right? If it's not coming from a window, how can I figure out which object is trying to message this deallocated MHControlsTabBarController?

There are a number of timer-based activities which check the state of this controls controller but in the document's -tearDown I try to stop all timers. The problem is, how can I ensure that all timers (and any actions already triggered) have stopped, before I go ahead tearing down everything else? I sort of need to delay the document closing somehow, but I asked about this in an earlier thread (this has been a loooong story) and was advised (probably rightly) that this was bad design. But this seems like a general problem to me, for which there is surely a general pattern which solves it. If I have timer-based activities, how do I make sure they are stopped before the rug is pulled from under their feet?

Many thanks for your patience with both of today's long posts.

Martin





_______________________________________________

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: Zombie object being messaged - why?
      • From: Quincey Morris <email@hidden>
    • Re: Zombie object being messaged - why?
      • From: Greg Parker <email@hidden>
    • Re: Zombie object being messaged - why?
      • From: Andy Lee <email@hidden>
    • Re: Zombie object being messaged - why?
      • From: Keary Suska <email@hidden>
  • Prev by Date: Re: NSTableView: bindings with drag and drop
  • Next by Date: Re: Zombie object being messaged - why?
  • Previous by thread: Re: NSTableView: bindings with drag and drop
  • Next by thread: Re: Zombie object being messaged - why?
  • Index(es):
    • Date
    • Thread