Possible memory problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible memory problem

chepe santacruz
Hello fellow developers,

Scenario:

I have written  an ImageJ  plugin that analysez a selected directory that
contains only images.
the program: - opens 1 image
                   - analyzes it
                   - closes the image
                   - opens the next image if any and repeats process untill
all images are analyzed.


Problem:

The program works fine for 1 image, 2 images...and so on but if there are 5
or more images the program freezes.

I suspect that i am running out of memory when i analyze > 4 images even
though I am using the ImagePlus.hide() method to close the window but i
don't think that it is enough. Is there some command i can use to something
i should do to free memory for an image i no longer need?

thank you,
Bill
Reply | Threaded
Open this post in threaded view
|

Re: Possible memory problem

Volker Baecker
Make sure you have no references left to the images no longer needed and
run a garbage collection (System.gc()) before loading the next image.
You can watch the memory usage with the Memory Monitor
(Plugins>Utilities>Monitor Memory)

Volker

chepe santacruz wrote:

> Hello fellow developers,
>
> Scenario:
>
> I have written  an ImageJ  plugin that analysez a selected directory
> that contains only images.
> the program: - opens 1 image
>                   - analyzes it
>                   - closes the image
>                   - opens the next image if any and repeats process
> untill all images are analyzed.
>
>
> Problem:
>
> The program works fine for 1 image, 2 images...and so on but if there
> are 5 or more images the program freezes.
>
> I suspect that i am running out of memory when i analyze > 4 images
> even though I am using the ImagePlus.hide() method to close the window
> but i don't think that it is enough. Is there some command i can use
> to something i should do to free memory for an image i no longer need?
>
> thank you,
> Bill
>

--
passerelle antivirus du campus CNRS de Montpellier
--
Reply | Threaded
Open this post in threaded view
|

Re: Possible memory problem

Albert Cardona
In reply to this post by chepe santacruz
Be sure to call the flush() method on each ImagePlus that you want to
discard, not just the hide()! And if you're processing the images
without user input for each, there is no need to call show() and then
hide() on each image.

Albert