[ImageJ-devel] when to close cursors, was Re: [fiji-devel] imglib coding style

Stephan Preibisch preibisch at mpi-cbg.de
Thu Apr 15 06:28:30 CDT 2010

Hi guys,

right now the Cursor.close() call is not necessary for any of the containers. But it will be when we start paging data and each Cursor will get a lock on the cell it currently works on. So when writing stuff using imglib one should think ahead and close cursors when they are not needed anymore. 

I do not really see how the new design should get rid of that paging-lock-cell problem Stephan -  how should it work without explicitly closing the cursor so that it releases the cell it is currently on when not needed anymore...
It might also be that Cursors have a local cache (which might be again an Image) they can empty when they are not needed anymore or that only a certain number of Cursors in parallel is allowed for some reason. 

Ciao ciao,

> -----Original Message-----
> From: Stephan Saalfeld [mailto:saalfeld at mpi-cbg.de]
> Sent: Donnerstag, 15. April 2010 00:34
> Cc: Johannes Schindelin; preibisch at mpi-cbg.de; fiji-
> devel at googlegroups.com; Imagejdev.org Developers
> Subject: Re: when to close cursors, was Re: [fiji-devel] imglib coding
> style
> Hi,
> Cursor.hasNext() == false does not mean that the cursor is out of image
> bounds and, depending on the container may still point to some data.
> Image keeping track of its cursors, it is good to close them for
> freeing
> this data.  Currently, this is important in cell containers only.
> I think that the recent design changes regarding data access make this
> tracking of cursors obsolete and so Cursor.close() too.  A good hint is
> that Image.removeCursor() is just never called.  But I am very tired
> and
> have to check this.
> Good night,
> Stephan
> On Wed, 2010-04-14 at 17:10 -0500, Curtis Rueden wrote:
> > Hi Johannes,
> >
> > At the hackathon Steffi told me it is best practice to always close
> > cursors. I had not done this in SquareTest so I committed a change
> > that now does so.
> >
> > Thanks,
> > Curtis
> >
> > On Wed, Apr 14, 2010 at 4:51 PM, Johannes Schindelin
> > <Johannes.Schindelin at gmx.de> wrote:
> >         Hi,
> >
> >         while writing a base class for JUnit tests, I realized that I
> >         did not
> >         close() the cursors when cursor.hasNext() returned false. Are
> >         you supposed
> >         to close() them even then?
> >
> >         Ciao,
> >         Johannes
> >
> >
> >

More information about the ImageJ-devel mailing list