[vtkusers] java memory

Jonathan Morra jonmorra at gmail.com
Tue Mar 29 11:10:19 EDT 2011


Thanks for your help.  For number 3, image.GetSpacing() is a VTK call,
however it returns a java double[], so I thought that it was OK.  All these
memory restrictions in Java make it very difficult to use, is there any
plans to improve the usage of VTK in Java?

Thanks again!

On Tue, Mar 29, 2011 at 5:26 AM, Sebastien Jourdain <
sebastien.jourdain at kitware.com> wrote:

> Hi Jonathan,
>
> I directly reply on the context of your mail,
>
>
> On Tue, Mar 29, 2011 at 2:33 AM, Jonathan Morra <jonmorra at gmail.com>
> wrote:
> > Since I'm using vtkJavaGarbageCollector I'm already using
> > vtkGlobalJavaHash.GC();.  The main questions that I currently still need
> > answered are here
> > 1.  should I have to call System.gc(); and System.runFinalization();
> > frequently with VTK+Java?  It appears the memory is managed better when
> > calling these lines every time vtkGlobalJavaHash.GC() is called, but I
> don't
> > know if this is necessary.
>
> System.gc(); is the only one that you should really care about. But
> Java does not offer any guarantee if this method will do something or
> not.  Moreover, the GC will stop all the thread to do its job. So it
> is basically up to you.
>
> > 2.  Is it ok to reuse Java variables?  Such as
> > vtkImageData image = filter.GetOuput();
> > // Do Stuff
> > image = filter2.GetOuput();
>
> yes
>
> > 3.   Is it OK to move around java objects without an intermediate
> reference?
> >  Such as
> > image1.SetOutputSpacing(image2.GetSpacing());
>
> what do you mean by Java object ? for me as the Set/Get do have a
> capital letter, I would say they come from the VTK world and if they
> return a vtkObject, you should use an intermediate variable otherwise
> if it's an array of primary type, that is just fine.
>
> > Sorry, forgot one more.  Should I be calling vtkGlobalJavaHash.GC() from
> the event dispatch thread?
> > I saw that as an option in vtkJavaGarbageCollector, and I'm not sure why
> that's the case.
>
> This totally depend on your VTK code, if you insure that all the call
> you are doing on the VTK layer is done through the EDT, then you
> should, otherwise you shouldn't. (This is a requirement if the data is
> shown in a renderer.)
>
> Seb
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110329/eb344b51/attachment.htm>


More information about the vtkusers mailing list