[vtkusers] VTK and Java Wrappers

Jeff Baumes jeff.baumes at kitware.com
Tue Mar 9 10:51:46 EST 2010


I agree that we should add a resolution for this issue in the upcoming VTK
release. The problem is that VTKDelete() happens in finalize(), which is run
on a separate thread and can cause concurrency issues. There are currently 3
proposed solutions (that I know of):

1. Use a shared mutex lock around every VTK call (including Delete()).
2. Have finalize() dispatch VTKDelete() calls to the thread that VTK objects
are allocated/used (normally the event thread).
3. Have no finalizers, but periodically traverse vtkGlobalJavaHash and
delete objects whose weak reference is null.

Denis Barbier has made patches on gitorious for solutions 1 and 2,
originally made by Nathan Sharp and Luke Dodd:

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 think I prefer the proxyFinalize solution (solution 2 above), but others
who have more experience with VTK+Java can give their opinions. I'll plan to
check in a fix in the coming days.

Thanks,
Jeff

On Mon, Mar 8, 2010 at 3:06 PM, egk865 at yahoo.com <egk865 at yahoo.com> wrote:

> Back in December, there was a discussion on this list about improving vtk's
> Java binding to better handle the freeing of vtk resources during garbage
> collection. Some of the ideas mentioned were global locks or adding a cmake
> option for disabling deletion of vtk objects during garbage collection and
> require the user to manually call Delete().
>
> With the recent announcement of the upcoming 5.6 branch, I was wondering if
> any final decisions have been made on this issue. Will there be any changes
> to the Java wrappers in the next release?
>
> I've experienced some of the crashes previously described and having
> already invested heavily in the Java wrappers for a moderately sized project
> (already close to 10000 lines of code) before becoming aware of these
> issues, I'm really hoping the Java wrappers have a bright future.
>
> Thanks,
> Eli
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>


-- 
Jeff Baumes, Ph.D.
R&D Engineer, Kitware Inc.
(518) 881-4932
jeff.baumes at kitware.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100309/e18020c1/attachment.htm>


More information about the vtkusers mailing list