Description
I am running a macro to individually process some images in a folder with a loop. For each iteration, it's a rather simple image preparation and then find circles with the Hough Circles plugin. The images I am running the plugin on are 1241x1754. There are approx. 100 circles in each image. I realized that the calls to this plugin are asynchronous, so I clean the results table at the beginning of each iteration and I wait for the results before proceeding with the next iteration. Also, I close every open image at the end of each iteration. However, after processing some images (fewer than 30), I get an out of memory error.
I am aware of the way the Java Virtual Machine works with memory. I made a test opening a large number of images to see how the memory gets used by the virtual machine until my memory limit. If I close them, the memory is not released, but I can open a large number of images again. Also if I force the garbage collector to run, the system gets back this memory.
This is not happening when I use the Hough Circle plugin. The memory is getting used, but then it's "blocked" ImageJ cannot use it anymore and if I force the garbage collector it's not getting back to the system. The only way of getting back this memory is closing ImageJ.