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

Nathan P Sharp vtkusers at nps.parcellsharp.net
Wed Dec 16 14:37:31 EST 2009


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




More information about the vtkusers mailing list