Re: multithreading textviews
Re: multithreading textviews
- Subject: Re: multithreading textviews
- From: Drew McCormack <email@hidden>
- Date: Thu, 22 Nov 2001 09:40:07 +0100
In Cocoa/Obj-C, an NSAutoReleasePool does the garbage collecting (to use
your native java terminology). It updates the retain count (reference
count) of each object which has been 'autoreleased' in the past event
loop iteration. If the count hits zero, the object is deallocated. The
thing you need to realize is that each thread needs to have its own
autorelease pool.
In java this is all taken care of for you, but I think what is going on
is that when you call NSTextView, the string is crossing the 'java
bridge', and the obj-C string is not being released because there is no
NSAutoReleasePool in that thread. Unfortunately, I don't have enough
experience with the java bridge to tell you the solution. But you could
definitely do worse than reading the cocoa docs under obj-C for
NSAutoReleasePool, and probably also NSThread. Also, read the docs about
the java bridge if you haven't already.
Drew McCormack
the multithreading seems to work from the commandline but with
NSTextView i get this
NSCFString autoreleased with no pool in place - just leaking
2001-11-22 01:12:38.223 CocoaPortScanner2[545] ***
_NSAutoreleaseNoPool(): Object 0x3dfbc40 of class NSCFString
autoreleased with no pool in place - just leaking
2001-11-22 01:12:38.277 CocoaPortScanner2[545] ***
_NSAutoreleaseNoPool(): Object 0x3dfbc60 of class NSCFString
autoreleased with no pool in place - just leaking
This is my call to the interface from within the thread
public synchronized void addToOutput(String value) {
output.append(value); // output is a stringbuffer
freeView = (NSTextView)displayViews.objectForKey("free"); // i
have my views in a dictionary for transport
freeView.setString(outputFree.toString());
freeView.displayIfNeeded();
}
Basically i don't understand the AutoReleasePool Part
Reading assignments welcome
Thanks
Cornelius
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
================================
Dr. Drew McCormack
Department of Theoretical Chemistry
Science Faculty
Free University Amsterdam
De Boelelaan 1083
1081 HV Amsterdam
The Netherlands
Email :: email@hidden
Tel. :: +31 20 44 47623
Fax :: +31 20 44 47629