[vtkusers] VTK/Java crashes -- WeakGlobalRef or garbage collection problem...solution?

Jeff Baumes jeff.baumes at kitware.com
Mon Dec 21 09:58:57 EST 2009


On Sat, Dec 19, 2009 at 6:11 AM, Denis Barbier <bouzim at gmail.com> wrote:
> On 2009/12/19 Nathan P Sharp wrote:
>> Denis Barbier escribió:
>>>
>>> Are you sure your copy is up-to-date?  Jeff fixed similar issues, see
>>> revisions 1.63 and 1.62.2.1 at
>>>    http://public.kitware.com/cgi-bin/viewcvs.cgi/Wrapping/vtkWrapJava.c
>>>
>> Yea, definitely a problem.  My original source is correct, but the build
>> directory created by CMake is wrong.  I'm going to blame innocence on
>> this one.  I am totally new to VTK and CMake as of about 5 days ago :-)
>> I'll get it fixed and report back if I find anything still leaking.
>
> In order to help evaluating Nathan's and Luke's patches, I created
> branches on gitorious.org, it is IMO simpler than working with patches
> against CVS.
> On Unix:
>  $ git clone git://gitorious.org/~dbarbier/kitware/dbarbier-vtk.git vtk-test
>  $ cd vtk-test
>  $ git checkout -b java/globalLock origin/java/globalLock
>  [build...install...test]
>  $ git checkout -b java/proxyFinalize origin/java/proxyFinalize
>  [build...install...test]
> I will update these branches if changes are sent to the list.

Thanks for putting those up on gitorious. It definitely makes it
easier to browse through the two solutions.

The proxyFinalize solution looks more elegant to me. So if I
understand correctly, you can write your own class that implements
vtkIDisposeOnThread, and call the static method setDisposer() to
change what happens in Java's finalize(). Is it true that you would
only want to change the disposer once at program startup? Perhaps that
should be clear in the documentation if so.

After we get a fix for this in CVS, it would be good to also commit
one or two tests that test extreme gc behavior to make sure this stays
fixed in the future.

I'll plan on committing proxyFinalize early next year if there aren't
serious objections. Until then, if you are a Java VTK developer,
please exercise this solution so we can make tweaks before it goes in.

Jeff



More information about the vtkusers mailing list