|
Bugzilla – Bug 990 |
Mac OS out of memory |
Last modified: 2015-02-18 12:20:38 CST |
| ⚠ |
NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug. The Fiji project now uses GitHub Issues for issue tracking. Please file all new issues there. |
|
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
Could you provide a small test macro that we can use to reproduce this problem? The following macro works as expected. The memory used by the four 512x512x100 temporary stacks it opens (25MB each) is reclaimed. newImage("Montage", "8-bit ramp", 1024, 1024, 100); x=0; y=0 for (i=0; i<4; i++) { newImage("Stack", "8-bit ramp", 512, 512, 100); run("Insert...", "source=Stack destination=Montage x=&x y=&y"); close(); x += 512; if (x==1024) { x = 0; y += 512; } } setBatchMode(false);Hi Wayne, First time replying on BugZilla, so hoping this is correct. Here are macros that [1] generates 4 stacks then [2] opens files, creates a montage and also prints out memory usage at each step. I’ve tried with various stack sizes. Behavior is not entirely consistent on any computer, sometimes all memory is released when the macro finishes with small stacks. But never with large stacks. When the finished montage does release memory,I was surprised that the memory for each component stack is not released when that stack is closed, only when the macro exits. This means the maximum size of a montage is 1/2 the available memory. I ran the debugger bug but saw nothing intelligible to me. macro "make stacks [1]"{ target=getDirectory("Source"); for (s=0;s<4;s++){ newImage("HyperStack", "16-bit ramp", 1024, 1024, 3,100,1); saveAs("Tiff",target+"Stack000"+s); } } macro "make montages [2]"{ dir=getDirectory("Source"); dirList=getFileList(dir); fList=newArray(0); print("Start Macro- Free memory:",IJ.freeMemory(), "Currently in use:",IJ.currentMemory()); newImage("Hyperstack", "16-bit composite-mode", 2048,2048,3,100,1); print("Create Stack- Free memory:",IJ.freeMemory(), "Currently in use:",IJ.currentMemory()); xx=0; yy=0; strname="montage"; grayopt="color_mode=Grayscale view=Hyperstack stack_order=XYCZT"; for(i=0;i<dirList.length;i++){ if(endsWith(dirList[i],".tif")||(endsWith(dirList[i],".tiff"))) fList=Array.concat(fList,dirList[i]); } for(f=0;f<fList.length;f++){ fpath=dir+fList[f]; //showStatus("Opening stack"); run("Bio-Formats Windowless Importer", "open=[fpath] [grayopt]"); rename("Source"); run("Insert...", "source=Source destination=Hyperstack x=xx y=yy"); run("Close"); print("Add Stack "+f+":",IJ.freeMemory(), "Currently in use:",IJ.currentMemory()); xx+=1024; if (xx==2048) { xx = 0; yy += 1024; } } run("Close"); //print("Free memory:",IJ.freeMemory(), "Currently in use:",IJ.currentMemory()); } regards Glen MacDonald Core for Communication Research Virginia Merrill Bloedel Hearing Research Center Cellular Morphology Core Center on Human Development and Disability Box 357923 University of Washington Seattle, WA 98195-7923 USA (206) 616-4156 glenmac@uw.edu On Jan 21, 2015, at 6:54 PM, bugzilla@fiji.sc wrote: Wayne Rasband changed bug 990 What Removed Added CC wsr@nih.gov Comment # 1 on bug 990 from Wayne Rasband Could you provide a small test macro that we can use to reproduce this problem? The following macro works as expected. The memory used by the four 512x512x100 temporary stacks it opens (25MB each) is reclaimed. newImage("Montage", "8-bit ramp", 1024, 1024, 100); x=0; y=0 for (i=0; i<4; i++) { newImage("Stack", "8-bit ramp", 512, 512, 100); run("Insert...", "source=Stack destination=Montage x=&x y=&y"); close(); x += 512; if (x==1024) { x = 0; y += 512; } } setBatchMode(false); You are receiving this mail because: • You are on the CC list for the bug. • You reported the bug.Hi Glen, I am not able to consistently reproduce this problem. Yesterday, when testing your macro, I noticed that sometimes not all memory was reclaimed after the macro finished and I ran the garbage collector by clicking on the status bar or "Memory" window. Today, however, the memory is always reclaimed after running the macro and clicking in the "Memory" window. The following version of your macro displays the "Memory" window and creates 10 montages. The "Make Montage" macro is first so you can run it by clicking on "Run" in Fiji's script editor. Watch the "Memory" window as the macro runs and you will see that memory is reclaimed as needed or you click in the "Memory" window. This version of the macro also fixes a few problems with passing variables and it removes the 'grayopt' string, which was not seen by the Insert command because it was not passed correctly. macro "Make Montage [1]" { dir=getDirectory("Source"); n = 10; list=getFileList(dir); for (i=0; i<n; i++) { montage = "Montage-"+(i+1)+"/"+n; newImage(montage, "16-bit composite-mode", 2048,2048,3,100,1); doCommand("Monitor Memory..."); x=0; y=0; for (f=0; f<list.length; f++) { fpath=dir+list[f]; //open(fpath); run("Bio-Formats Windowless Importer", "open=&fpath"); rename("Source"); run("Insert...", "source=Source destination=&montage x=&x y=&y"); close; x += 1024; if (x==2048) { x = 0; y += 1024; } } close; } } macro "Make Stacks [2]" { target=getDirectory("Choose Directory"); newImage("HyperStack", "16-bit ramp", 1024, 1024, 3,100,1); for (s=0;s<4;s++) saveAs("Tiff",target+"Stack000"+s); }Hi Glen, You should not expect memory to be released at each iteration or when the macro finishes. The garbage collector will run as needed to reclaim memory and prevent OOM errors. If you are still getting OOM errors, try replacing run("Bio-Formats Windowless Importer", "open=&fpath"); with open(fpath);