!7 static int n = 20000; p { for (int tableSize = 0; tableSize < 100; tableSize += 10) { O[] data = arrayOfBlankObjects(tableSize); O[] array = new O[n]; long mem1 = usedMemoryAfterGC(); for i over array: { new HashMap hashMap; for (O x : data) hashMap.put(x, x); array[i] = hashMap; } long mem2 = usedMemoryAfterGC(); double objSize = (mem2-mem1)/(double) l(array); int rounded = iround(objSize); long f = guessHashMapSize(tableSize); print("Hash table size=" + tableSize + ". Approximate object size: " + objSize + " => " + rounded + " bytes. Formula: " + f); } }