[vtkusers] VTK/Java crashes -- WeakGlobalRef or garbage collection problem...solution?
Nathan P Sharp
vtkusers at nps.parcellsharp.net
Thu Dec 17 17:33:59 EST 2009
Luke Dodd escribió:
> Nathan: Could you explain your suggestion with a
> "vtkJavaGarbageCollectionContext" a little more? Do you think it is
> worth doing if the global lock works?
>
>
I'll take anything that works and be happy :-) However, personally I'd
still prefer to have explicit control over it (and would sleep better in
the face of worries about openGL theading restrictions).
Currently even if I go through and explicitly call Delete() on about
everything I can get my hands on, it is still leaking GDI objects and
memory. This might be an unrelated issue, I don't know. Is there
something else I should be doing while closing a vtkCanvas? DeleteAll()
is not an option because there might be other charts open.
Re: vtkGCContext
I want to get rid of vtkGlobalJavaHash in favor of passing in a
"context" object. I want to write code like this:
public class MyVTKChart extends JPanel
{
private vtkCanvas _canvas;
private vtkObjectContext _context; //this is really just a map
pubic MyVTKChart()
{
_context = new vtkObjectContext();
_canvas = new vtkCanvas(_context);
// create sphere geometry
vtkSphereSource sphere = new vtkSphereSource(_context);
sphere.SetRadius(1.0);
sphere.SetThetaResolution(18);
sphere.SetPhiResolution(18);
// map to graphics objects
vtkPolyDataMapper map = new vtkPolyDataMapper(_context);
//the object returned by sphere.GetOutput() automatically uses
_context
map.SetInput(sphere.GetOutput());
...
}
//Clear all vtk resources associated with this class. Only
//call after disposing the form
public void Delete()
{
_context.DeleteAll();
}
...
Underneath the hood, vtkObjectContext is exactly like vtkGlobalJavaHash,
only it uses strong references instead of weak.
I really appreciate all your help on this.
Nathan
More information about the vtkusers
mailing list