Jiang Wu wrote:
> TclObject listElement = TclList.index(...);
> listElement.preserve();
> listElement.toString();
> listElement.release();
This doesn't seem too horrible...
> Or we can try to fix the CObject finalize. I propose something like this:
[...]
> Any comments?
Finalization is tricky. Think about the corner cases... sometimes
finalize() may be invoked when the heap is already nearly exhausted, and
any finalized objects won't be freed until the next GC cycle. Your
proposed finalize() method may try to allocate memory (as a side effect
of addElement) which could force a deadlock, depending on how
finalization is implemented.
I was thinking about adding a `next' member to CObject, to build a
singly-linked list of finalized objects without allocating memory.
Unfortunately it would still probably require synchronization.
Finalizing large numbers of objects tends to be detrimental to GC
performance, delaying reclamation of dead objects much longer than
normal. Keeping finalizable objects small or few in number helps.
I tend to welcome simplicity and fight complexity, so I'd rather try
your first suggestion.
--
Jeff Sturm
[EMAIL PROTECTED]
----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe: send mail to [EMAIL PROTECTED]
with the word SUBSCRIBE as the subject.
To unsubscribe: send mail to [EMAIL PROTECTED]
with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'.
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com