4 import java.awt.image.*;
5 import java.util.Vector;
13 public void run(String arg) {
16 "The MemoryTest plugin opens as many\n"
17 +
"1024x1024x8-bit images as possible and then\n"
18 +
"calculates how much memory was used for each\n"
19 +
"image. This is a demanding test that may require\n"
20 +
"ImageJ to be restarted, may crash your browser, \n"
21 +
"or may even crash your machine."
27 int arraySize = 1024*1024;
33 Image img, saveImg=null;
36 IJ.
write(
"Opening " + width +
"x" + width +
" 8-bit image windows...");
38 int[] times =
new int[2000];
40 time = System.currentTimeMillis();
43 NewImage.open(
""+(nImages+1), width, width, 1, NewImage.GRAY8, NewImage.FILL_WHITE);
44 time2 = System.currentTimeMillis();
45 times[nImages] = (int)(time2-time);
50 catch(OutOfMemoryError ex) {
55 objects =
new Vector();
60 byte[] a =
new byte[arraySize];
61 objects.addElement(a);
67 catch(OutOfMemoryError e) {
70 IJ.
write(arraySize*nArrays/(1024*1024) +
"MB is available");
71 IJ.
write(nImages +
" images were opened");
73 IJ.
write(
"~" + arraySize*nArrays/(nImages*1024) +
"K was required for each image");
82 void collectGarbage() {
83 for (
int i=0; i<10; i++)