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

Jeff Baumes jeff.baumes at kitware.com
Tue Nov 17 09:53:00 EST 2009


On Tue, Nov 17, 2009 at 9:42 AM, Baliki baliki <balikivtk at gmail.com> wrote:
> The crash happened afterwards.
> The data rendered ok. But when i interacted with the rendered object, sooner
> or later the program would crash. The same thing happened when i changed the
> size of the window (expected so, as it makes the object to be updated, if
> i'm not mistaken).

Ok. You really need to keep some VTK object stored externally. It's an
artifact of the wrapping system, but not a bug that can be fixed (at
least to my knowledge). There needs to always be a VTK object (or set
of objects) that is not out-of-scope that will keep references to
everything, otherwise all VTK objects will be deleted on garbage
collection. In your case just storing the render window at the class
level should do the trick.

Not sure why this would not be an issue with a different reader.
Perhaps the other reader uses less memory and Java does not
garbage-collect as soon, so it appears to work a long time?

Jeff



More information about the vtkusers mailing list