无论我使用Long[]
,Integer[]
还是ArrayList<Integer>
, 为什么它们都返回相同的内存使用量?
System.out.println("Memory Usage : " + Runtime.getRuntime().totalMemory()/(1024*1024));
System.out.println("Memory Usage : " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/(1024*1024));
//Long[] aa = new Long[70000000];
Integer[] bb = new Integer[70000000];
//ArrayList<Integer> a = new ArrayList<Integer>(70000000);
System.gc();
System.out.println("Memory Usage : " + Runtime.getRuntime().totalMemory()/(1024*1024));
System.out.println("Memory Usage : " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/(1024*1024));