Problem closing images
Posted by strahli on Jun 27, 2011; 9:32am
URL: http://imagej.273.s1.nabble.com/Problem-closing-images-tp3683887.html
Hei everybody.
I'm working with ImageJ and Java for a month now. My task is it to read an Image every 10 seconds from a camera, compare it to a reference image and create a result Image (shows the differences). Means that I need to have 3 images open at once. I can repeat this process about 260 times until the <Out of memory> exception comes. My problem is that I tried to close the Images, but if I do this, I get another NullPointerException.
================================
My code is like this:
start timer
if (timerEvent) {
loadNewPicture();
}
loadNewPicture{
result = manipulate(refImage, snapshot);
...
}
manipulate (refImage, snapshot) {
if (refWindow == null) {
refWindow = new ImageWindow(refImage)
} else {
refWindow.setImage(refImage)
}
// the same for the snapshot
// execution of some macros
Image result = WindowManager.getCurrentImage().getImage();
return result;
}
================================
My problem is that I tried to close the images or the windows but if I do this , I get an exception in the class "ImageWindow" at row 526 (method "windowActivated" line: setMenuBar(Menus.getMenuBar());).
Btw: the image size is ca.70 KB.
Has anybody a hint for me?
Thanks in advance,
strahli
EDIT: And I've searched the older topics, but I didn't really found a solution except for closing the images, windows and using the garbage collector, but I can't really adapt it to my programm without getting other problems.