[vtkusers] VTK/Java crashes -- WeakGlobalRef or garbage collection problem...solution?
Luke Dodd
luke.dodd at gmail.com
Mon Dec 21 16:37:31 EST 2009
> I meant something like:
> package vtk;
> class vtkDisposeCurrent implements vtkIDisposeOnThread
> {
> public void disposeOnThread(long id)
> {
> vtkObjectBase.VTKDelete(id);
> }
> }
> With this class, current behavior is unchanged, I do not understand
your objections here.
This would mean that delete was called from the finalizer thread -
which was the cause of the original errors. (finalizer calls
finalize(), which in turn calles the disposeOnThread you provided
which in turn calles VTKDelete). Sorry if I'm misunderstanding this...
> * Add vtkJavaDisposeCurrent which calls vtkObjectBase.VTKDelete(idf)
in the current thread (and thus mimic current behavior)
I believe that vtkJavaDisposeEDT should still be the default behavior.
So the default behaviour should be to not apply any of the patches
(and thus crashing)? Or are we somehow breaking out of the finalizer
thread in your code above?
> That's true in theory, but if you rely on memory being freed by a
thread before being allocated by another thread, you are likely to get
into trouble anyway.
That's what "Java programmers" expect, it's essentially what GC on a
single threaded java program is, so it would be worth at least making
this obvious in the documentation.
More information about the vtkusers
mailing list