• 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 reference held by NSSavePanel?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDocument reference held by NSSavePanel?


  • Subject: NSDocument reference held by NSSavePanel?
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 12 Apr 2009 20:33:35 -0700

Here's something strange. I have a NSDocument-based GC app whose data model contains an object that uses a resource. (The resource is actually exclusive access to a MMC-controlled device, but that's not really relevant.) The object has a finalize method in which the resource is released.

This all works most of the time. The object is created (and therefore acquires its resource) when a new document is being created, or when an existing document is being opened. When the document window is closed, everything gets garbage collected, the finalize method is called, and the resource is released.

However, if I close the document window after using the Save As dialog (either for the initial save of a new document, or for a save-as of an existing document), the resource is NOT released, because the finalize method isn't being called, because there's still a reference to that object.

Here's what the debugger says about that reference:

(gdb) info gc-roots 0x1225400
Number of roots: 1
Root:
0 Kind: global rc: 0 Address: 0xa03f1214 Symbol: shared.176062
warning: can't find class named `NSToolTipManager' given by ObjC class object
1 Kind: object rc: 0 Address: 0x01050350 Offset: 0x00000008 Class: NSToolTipManager
warning: can't find class named `a' given by ObjC class object
2 Kind: object rc: 0 Address: 0x0104f320 Offset: 0x00000010 Class: NSCFArray
3 Kind: bytes rc: 0 Address: 0x013d7200 Offset: 0x00000040
warning: can't find class named `NSToolTip' given by ObjC class object
4 Kind: object rc: 0 Address: 0x010f8d30 Offset: 0x00000014 Class: NSToolTip
warning: can't find class named `a' given by ObjC class object
5 Kind: object rc: 0 Address: 0x010f8cd0 Offset: 0x00000030 Class: NSCFDictionary
6 Kind: bytes rc: 0 Address: 0x010f8d20
warning: can't find class named `NSNavBrowserCell' given by ObjC class object
7 Kind: object rc: 0 Address: 0x01326420 Offset: 0x00000014 Class: NSNavBrowserCell
warning: can't find class named `NSNavMatrix' given by ObjC class object
8 Kind: object rc: 0 Address: 0x01428d60 Offset: 0x00000030 Class: NSNavMatrix
9 Kind: object rc: 0 Address: 0x01082380 Class: NSSavePanel ivar: _spAuxiliaryStorage
warning: can't find class named `NSSavePanelAuxiliary' given by ObjC class object
10 Kind: object rc: 0 Address: 0x010c9540 Offset: 0x00000010 Class: NSSavePanelAuxiliary
11 Kind: object rc: 0 Address: 0x01096e80 Class: BPMDocument ivar: mutableModel

etc, eventually leading to the object that has the resource. BPMDocument is the application's NSDocument subclass, and mutableModel is the document's data model.


This appears to say that the save panel is holding a reference to the document. Does this make any sense to anyone?


_______________________________________________

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 reference held by NSSavePanel?
      • From: Corbin Dunn <email@hidden>
    • Re: NSDocument reference held by NSSavePanel?
      • From: Michael Ash <email@hidden>
  • Prev by Date: Re: Converting String Representations at Runtime
  • Next by Date: Re: How to open two nibs at app launch ? Beginners question
  • Previous by thread: CGContextClipToMask
  • Next by thread: Re: NSDocument reference held by NSSavePanel?
  • Index(es):
    • Date
    • Thread