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

Luke Dodd luke.dodd at gmail.com
Mon Dec 21 15:10:35 EST 2009


> * Add vtkJavaDisposeCurrent which calls vtkObjectBase.VTKDelete(idf) in the current thread (and thus mimic current behavior)

If I understand you correctly vtkJavaDisposeCurrent would make the
object be Deleted on whatever thread it was created? As far as I know
there is no way to make a thread take an action (e.g. call a Delete
method) in the general case. It is possible with the EDT because it is
designed in such a way (you push operations for it to perform onto a
queue, so it will get there hopefully (gui events are just things
pushed into that queue)).

If someone was using a "normal" thread (one that is constantly
performing operations) there is no way to give "inject" some operation
for it to do, say delete an object. So this way of doing things only
works in the case of a GUI application that spends plenty of time
waiting for user input, or when the programmer has created a special
queue and taken care to clear it occasionally (this would involve
writing a custom disposer class and maintaining queue).

There is one more problem I can imagine occurring. If some code
running on the EDT creates lots of vtk objects, many of which can be
disposed of after some point of execution, we could run out of memory
before this code completes even though there are lots of objects
available delete. The objects to delete would simply be on the end of
the EDT queue and never get seen to because we would run out of memory
first. Certainly an application could end up peaking at more memory
usage than necessary. This is probably not as severe as it sounds,
it's a corner case, but worth thinking about.

There is more detail in the last message I sent that you may or may
not have read yet.

This does not actually affect because my application is swing based,
I'm just thinking about other more general vtk use cases - this method
seems a little "fragile". My only other objection is that the EDT is
not "meant" to be used like this, but we are already in fairly hacky
territory so that's not such a big deal.

Thanks,
Luke



More information about the vtkusers mailing list