Re: [tcljava-dev] Testcase for bug 2072924
Brought to you by:
mdejong
From: Tom P. <tpo...@ny...> - 2009-03-19 03:06:07
|
On Mon, Feb 02, 2009 at 11:19:52PM -0800, Mo DeJong wrote: > The short answer is that you have in fact found a bug. The longer answer > is I need to look at it some more to really be sure the fix is right. > Here is a trimmed down test case that reproduces the problem without > Itcl or anything else involved. [...] > Now, you can get these fixed results by making the change described in > this patch, but this is just a work in progress. It is for hacking > purposes only! > > diff -u -r orig/jacl1.4.1/src/tcljava/tcl/lang/ReflectObject.java > jacl1.4.1/src/tcljava/tcl/lang/ReflectObject.java > --- orig/jacl1.4.1/src/tcljava/tcl/lang/ReflectObject.java Thu Apr > 13 00:36:50 2006 > +++ jacl1.4.1/src/tcljava/tcl/lang/ReflectObject.java Mon Feb 2 > 22:38:48 2009 > @@ -512,7 +512,7 @@ > > ReflectObject roRep = findInReflectTable(interp, cl, obj); > > - if (roRep != null) { > + if (roRep != null && roRep.isValid) { > // If it is already in the table just increment the use count > and return > it > > roRep.useCount++; > > > I am not 100% sure about this patch, because it seems that the > duplicated entries and not being cleared out of the reflect table like > they should be. More on that to come. I have another patch that might work. For my use cases, it seems to avoid leaking objects. The patch is your code above, plus invoking 'dispose()' at the end of 'disposeCmd()' method: diff -r -u tcljava/src/tcljava/tcl/lang/ReflectObject.java tcljava.ae/src/tcljava/tcl/lang/ReflectObject.java --- tcljava/src/tcljava/tcl/lang/ReflectObject.java 2008-12-23 19:36:01.000000000 -0700 +++ tcljava.ae/src/tcljava/tcl/lang/ReflectObject.java 2009-03-17 21:12:57.000000000 -0600 @@ -512,7 +512,7 @@ ReflectObject roRep = findInReflectTable(interp, cl, obj); - if (roRep != null) { + if (roRep != null && roRep.isValid) { // If it is already in the table just increment the use count and return it roRep.useCount++; @@ -949,6 +949,7 @@ } isValid = false; + dispose(); } ^L -- Tom Poindexter tpo...@ny... |