Memory Leak - NSView with custom accessibility info
Memory Leak - NSView with custom accessibility info
- Subject: Memory Leak - NSView with custom accessibility info
- From: "Bobby Thomale" <email@hidden>
- Date: Fri, 28 Apr 2006 10:34:44 -0500
I am working on trying to add accessibility support to a future
version of our application.
I am running into some problems with memory leaks in AppKit.
We have a custom text view object - it is our own subclass of NSView.
I overrode accessibilityIsIgnored in this class and the other
NSAccessibility protocol methods; very standard, very simple stuff.
There are no custom accessibility child objects or anything, all it
does is return the text contents of the view and implements the
various attributes for returning text and text position info.
Yesterday I discovered a memory leak - my custom text view is not
being deleted anymore. I traced the leak back specifically to the
accessibility code. Changing accessibilityIsIgnored back to YES makes
the leak go away.
I can see (using ObjectAlloc) all of the retains and releases that
have been performed on our NSView object, so I can see where the
accessibility code is retaining me and not doing any releases. I can
match all of the other retains and releases to each other but there
seem to be 4 extra retains in the NSNibAXRelationshipConnector when
the bundle is being loaded.
Here is what one looks like:
Event: (#2031723) ObjectRetainedEvent
Time Index: 167856683.867470
Category: DashRenderView
Pointer: 0x72e4680 Size: 176
Thread: 0xd03 Extra Data: 0x0
Backtrace:
-[NSView retain]
CFArrayCreate
-[NSPlaceholderArray initWithObjects:count:]
-[NSArray initWithObjects:]
-[NSNibAXRelationshipConnector establishConnection]
-[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:]
loadNib
+[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:]
+[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:]
+[NSBundle(NSNibLoading) loadNibNamed:owner:]
-[MainController openBook:] crt.c:355
-[MainController openURI:] crt.c:355
-[MainController openURI:withElementID:] crt.c:355
-[BookshelfResultsController openSelectedItems:] crt.c:355
-[NSApplication sendAction:to:from:]
-[NSControl sendAction:to:]
-[NSTableView _sendAction:to:row:column:]
-[NSTableView mouseDown:]
-[BookshelfBooksView mouseDown:] crt.c:355
-[NSWindow sendEvent:]
-[NSApplication sendEvent:]
-[NSApplication run]
NSApplicationMain
main() crt.c:355
_start() crt.c:272
start
I didn't bother pasting them all but I get 4 of these retains (with an
identical stack trace) right in a row.
What I am trying to figure out is who or what in Appkit actually owns
the arrays that are being created here, so I can figure out if I am
somehow creating an ownership cycle or leaking some other object that
is keeping these busy. Or it is possible there's an AppKit bug here
causing this leak, I dunno. But this stuff is undocumented, as it is
all internal Appkit stuff.
The window that the view is contained in is instantiated from a NIB
using loadNibNamed:owner: and specifying a custom window controller. I
verified that our custom controller is deleting all of the top level
objects from the NIB, unless there are some hidden ones I don't know
about. I wasn't sure if there is something secret and magical that
NSWindowController does to free up the AX relationships that our
custom class knows nothing about; I expected them to all be taken care
of when the window is closed and released. As far as I can tell the
window is closing and deleting just fine.
Anyway, this is a case where my debugging efforts have finally run up
against the brick wall of internal Appkit classes, where I need more
information to go any further. Any help would be appreciated - even if
you can't exactly solve my problem, even knowing how these objects are
supposed to be cleaned up would be a big help.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden