Java's RAM usage doesn't correspond to what the Task Manager says
问题 I have been playing with Java's JVM by making a 1024^3 (basically 1Gb) length byte array. I measured the RAM usage before, after the array creation and after the array's destruction by the garbage collector, using both the Task Manager (looking at the process) and this little snippet: public static void showMemory() { System.out.println("Memory used: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024.D * 1024.D) + "mB."); } The aforementioned code shows 2Mb,