class MemoryTest {
protected static final long COUNT = 100;
public static void main(String[] arg) {
long start, end, difference;
Object[] array = new Object[COUNT];
long i;
Runtime.getRuntime.gc();
// let's hope the
// garbage collector runs
start = Runtime.getRuntime().totalMemory();
for (i = 0;
i < COUNT;
i++) {
array = new Object();
}
Runtime.getRuntime.gc();
end = Runtime.getRuntime().totalMemory();
difference = (end - start) / COUNT;
System.out.println("Approximately " + difference
+ " bytes used by 1 java.lang.Object with
default constructor");
}
}