使用命令 -Xms500m -Xmx139000m 获得 104 Gp 堆内存
我正在使用核心 i5 处理器 64 位 Windows 7 操作系统。500 Gp 硬盘。仅 4GB 内存
我只想知道 Jvm 从哪里获取 104 GB(heap) 的内存?
在输出中没有显示内存使用情况?
`public class CPUusage { public static void main(String[] args)throws Exception { int mb = 1024*1024; int GB = 1024*1024*1024; /* Total number of processors or cores available to the JVM */ System.out.println("Available processors (cores): " + Runtime.getRuntime().availableProcessors()); /* Total amount of free memory available to the JVM */ System.out.println("Free memory (MB): " + Runtime.getRuntime().freeMemory()/mb); /* This will return Long.MAX_VALUE if there is no preset limit */ long maxMemory = Runtime.getRuntime().maxMemory()/GB; /* Maximum amount of memory the JVM will attempt to use */ System.out.println("Maximum memory (GB): " + maxMemory); /* Total memory currently in use by the JVM */ System.out.println("Total memory (MB): " + Runtime.getRuntime().totalMemory()/mb); /* Get a list of all filesystem roots on this system */ File log=new File("D:\\log.txt"); log.createNewFile(); FileWriter fstream = new FileWriter(log); BufferedWriter out = new BufferedWriter(fstream); out.write("--------------------------------------------"+"\n\n"); out.write("Available processors (cores): " + Runtime.getRuntime().availableProcessors()); out.newLine(); out.write("Free memory (MB): " + Runtime.getRuntime().freeMemory()/mb); out.newLine(); out.write("Maximum memory (MB): " + (maxMemory == Long.MAX_VALUE ? "no limit" : maxMemory)); out.newLine(); out.write("Total memory (MB): " + Runtime.getRuntime().totalMemory()/mb); out.newLine(); File[] roots = log.listRoots(); /* For each filesystem root, print some info */ for (File root : roots) { System.out.println("-------------------------------------------"); System.out.println("File system root: " + root.getAbsolutePath()); System.out.println("Total space (GB): " + root.getTotalSpace()/GB); System.out.println("Free space (GB): " + root.getFreeSpace()/GB); System.out.println("Usable space (GB): " + root.getUsableSpace()/GB); out.write("-------------------------------------------"); out.newLine(); out.write("File system root: " + root.getAbsolutePath()); out.newLine(); out.write("Total space (GB): " + root.getTotalSpace()/GB); out.newLine(); out.write("Free space (GB): " + root.getFreeSpace()/GB); out.newLine(); out.write("Usable space (GB): " + root.getUsableSpace()/GB); out.newLine(); } out.write("-------------------------------------------"); out.newLine(); out.close(); } } `
输出是
`Available processors (cores): 4 Free memory (MB): 476 Maximum memory (GB): 104 Total memory (MB): 479 ------------------------------------------- File system root: C:\ Total space (GB): 97 Free space (GB): 70 Usable space (GB): 70 ------------------------------------------- File system root: D:\ Total space (GB): 368 Free space (GB): 366 Usable space (GB): 366 `