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

Clinton Stimpson clinton at elemtech.com
Wed Dec 16 15:15:22 EST 2009


How does this relate?
<http://publib.boulder.ibm.com/infocenter/javasdk/v6r0/index.jsp?topic=/com.ibm.java.doc.diagnostics.60/html/mm_gc_coexist.html>
"The Java service team strongly recommends that applications avoid the use of 
finalizers as far as possible.  The JVM specification states that finalizers 
should be used as an emergency clear-up of, for example, hardware resources."

Seems to me a can of worms if one attempts to make the garbage collector 
thread safe.

Clint

On Wednesday 16 December 2009 12:37:31 pm Nathan P Sharp wrote:
> I am also seeing crashes from VTK/Java :-(  On debugging I've noticed
> that the calls to VTKDelete() are happening on the Java Finalizer
> thread.  Since VTK is not thread safe, lines like the following from
> vtkObjectBase::UnRegisterInternal are unpredictable.
>
>   if(--this->ReferenceCount <= 0)
>
> I have been trying to solve the problem the same way, by ensuring that I
> keep around the Java objects and then calling Delete() myself on them on
> the right thread.  However, some of the internals to vtkCanvas and
> vtkPanel are creating temp objects and then letting them go.  From
> vtkPanel.java line 150:
>
>  lgt.SetPosition(cam.GetPosition());
>
> Would making the vtk garbage collection thread safe be a possible
> route?  Are there other ideas out there?
>
>  Nathan
>
> _______________________________________________
> 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




More information about the vtkusers mailing list