java.lang.InternalError: The current process has used all of its system allowance of handles for Window Manager objects

@Wayne

This is a continuation of a recent thread: Custom result table size limit ? Window manager objects. I found an issue with and it was suggested that I contact you as it may be a bug.

There seems to be a limit to the number of times a macro can create a histogram from an image and close it WITH setbatchMode(true) before Fiji freezes and gives the following message in the macro editor:

java.lang.InternalError: The current process has used all of its system allowance of handles for Window Manager objects.

	at sun.awt.windows.WToolkit.eventLoop(Native Method)
	at sun.awt.windows.WToolkit.run(WToolkit.java:312)
	at java.lang.Thread.run(Thread.java:748)

This is the macro I used:

stackMax = 255;
//dir6NaN = "D:/USERS/DavidChatelet/IssuesTest_20201106/TEST/";
setBatchMode(true);

for(i=1; i<=10; i++){
	for(n=1; n<=nSlices; n++){
		print("Round "+i+" - histogram image "+n+" / "+nSlices);
		setSlice(n);
		//run("Duplicate...", "title=temp");
		run("Histogram", "bins="+stackMax+" x_min=0 x_max="+stackMax+" y_max=Auto");
		wait(500);
		//saveAs("Tiff", dir6NaN+"Histog_Tissue_Intensity_Slice"+n+".tif");
		//close();
		close("Histo*");
		//close("temp");
		wait(500);
	}
}
exit("DONE");

When setBatchMode(true) is commented out, the macro runs through more than 3 rounds without issues.
When setBatchMode(true) is active, the macro runs until round 2 - slice 400ish before it stops and tells me that all allowed handles have been used.
When I duplicate the slice and create an histogram and close it, same story.
But when I duplicate the slice and close it without creating an histogram, no errors appear, even with setBatchMode(true) activated.

I am using a windows 10 64-bit machine with 128GB of RAM, with Fiji ImageJ 2.0.0-rc-72/1.53f; java 1.8.0_172
I am running the above macro on a 416 image (32bit, 428x355 pixels) imported as image sequence (https://drive.google.com/file/d/1JJwi9VQu7ntwbmjv3WVot6CqMn5SQZym/view?usp=sharing)

Following suggestion from the previous thread, I used Process Explorer (correctly I think) to list the handles associated with ImageJ Win64.exe (attached txt file). Maybe that will help.
ImageJ-win64.exe.txt (132.4 KB)

Is this a bug? Or is this something that has always been there and I was not aware of it?

Thank you.

1 Like