• 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
NSDocument leak with top-of-NIB object controllers (10.6 ARC)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDocument leak with top-of-NIB object controllers (10.6 ARC)


  • Subject: NSDocument leak with top-of-NIB object controllers (10.6 ARC)
  • From: Fritz Anderson <email@hidden>
  • Date: Thu, 22 Dec 2011 13:29:40 -0600

Xcode 4.2, 10.7 SDK, target 10.6, ARC ("weak" pointers must be unsafe_unretained).

I had the following problem, which I solved, but I don't trust the solution:

When I used heapshotting to see what happened when I repeatedly opened and closed my document, I was accumulating a lot of memory as the document and its data were never released. All the retains and releases with my code in the stack trace were balanced.

The document's NIB (no, I don't put the document in the NIB, and I'm using the window controller that comes with the document) contains an NSObjectController and an NSArrayController at the top level. Per "Patterns for Managing Outlets Become Consistent Across Platforms" in the "Transitioning to ARC Release Notes," the IBOutlet properties for those controllers were declared strong.

But my residual retain count was 2, and a couple of the retains were in the NIB-loading mechanism, so I tried setting the outlets for those controllers to nil at -windowWillClose: time.

This cured the leak. So did making the outlets unsafe_unretained (though that leaked slightly more).

I don't see that there should be _harm_ in this, but I worry, because it goes against the documentation (at least the documentation I could find). I've developed a theory, and I'd like to know if it's superstitious:

• For projects targeting 10.7 or later, and using ARC, the references should be strong, as documented. (But how does the OS know whether that class in particular is using ARC? Products can be mixed.)

• If the target is 10.6, even if running on 10.7, regardless of whether ARC is used, the references should be unsafe_unretained/assign, to match the behavior of the target operating system.

Do I have this right?

	— F

_______________________________________________

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: NSDocument leak with top-of-NIB object controllers (10.6 ARC)
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: presentingViewController docs patently false
  • Next by Date: Re: NSDocument leak with top-of-NIB object controllers (10.6 ARC)
  • Previous by thread: Re: No more warning about registered observers on dealloc with ARC?
  • Next by thread: Re: NSDocument leak with top-of-NIB object controllers (10.6 ARC)
  • Index(es):
    • Date
    • Thread