Properly Releasing NSWindows
Properly Releasing NSWindows
- Subject: Properly Releasing NSWindows
- From: email@hidden
- Date: Thu, 15 Apr 2004 22:22:01 -0400 (EDT)
I have been using cocoa/java for a while now, and I have worked my way
through a number of java gc vs objC releasing issues, but I just can't
seem to figure this one out.
If I make an NSWindow programmatically from Java, whenever I close the
window I get a segfault between 0 and 30 seconds later (pretty quick after
the next gc, unsurprisingly). So, the window is getting gc'd by java, but
somehow objC still is trying to access it. But why is it trying to access
the window, and how can I stop it?
When I close the window, it disappears from the window list
(NSApplication.sharedApplication().windows()) as I would expect. I also
called "setOneShot(true)" and "setReleasedWhenClosed(true)" for good
measure. This happens with or without an NSWindowController. Oh yes,
also I keep java pointers to the window while it is open, then get rid of
them on close, so that it can get gc'd.
In desperation I also tried calling release on the NSWindow through the
bridge, and adding it to an NSArray and removing it again to jog its
reference count, all to no avail.
I saw that this question was asked before (either here or in the java
list) and that someone suggested keeping pointers to the NSWindow around
java-side. This would certainly fix the problem, but then none of my
windows will ever get gc'd...
I have worked around this where necessary by never closing windows (just
hiding them), but for some situations where you want a variable number
of windows opening and closing a lot that gets pretty silly.
Anyone know why objC is trying to access the window, or what to do about
it? Thanks!
-jg
_______________________________________________
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.