//操作系统信息
OperatingSystemMXBean osm = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
System.out.println("osm.getName() "+osm.getName()); //名字
System.out.println("osm.getVersion() "+osm.getVersion()); //版本
System.out.println("osm.getArch() "+osm.getArch()); //数据结构(32位、64位)
System.out.println(osm.getFreePhysicalMemorySize()/1024/1024); //空闲内存
System.out.println(osm.getTotalPhysicalMemorySize()/1024/1024); //总内存
//jvm 信息
RuntimeMXBean rmb=(RuntimeMXBean)ManagementFactory.getRuntimeMXBean();
System.out.println("getVmVersion "+rmb.getVmVersion()); //版本
System.out.println("getVmName "+rmb.getVmName()); //名称
System.out.println("getClassPath "+rmb.getClassPath()); //classPath
System.out.println("getLibraryPath "+rmb.getLibraryPath()); //libraryPath
MemoryMXBean mm=(MemoryMXBean)ManagementFactory.getMemoryMXBean();
System.out.println("getHeapMemoryUsage "+mm.getHeapMemoryUsage()); //堆内存
System.out.println("getNonHeapMemoryUsage "+mm.getNonHeapMemoryUsage()); //非堆内存
List<MemoryPoolMXBean> mpmList=ManagementFactory.getMemoryPoolMXBeans(); //内存详细信息 eden suviver old perm
for(MemoryPoolMXBean mpm:mpmList){
System.out.println("getUsage "+mpm.getName()+":"+mpm.getUsage());
}
OperatingSystemMXBean osm = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
System.out.println("osm.getName() "+osm.getName()); //名字
System.out.println("osm.getVersion() "+osm.getVersion()); //版本
System.out.println("osm.getArch() "+osm.getArch()); //数据结构(32位、64位)
System.out.println(osm.getFreePhysicalMemorySize()/1024/1024); //空闲内存
System.out.println(osm.getTotalPhysicalMemorySize()/1024/1024); //总内存
//jvm 信息
RuntimeMXBean rmb=(RuntimeMXBean)ManagementFactory.getRuntimeMXBean();
System.out.println("getVmVersion "+rmb.getVmVersion()); //版本
System.out.println("getVmName "+rmb.getVmName()); //名称
System.out.println("getClassPath "+rmb.getClassPath()); //classPath
System.out.println("getLibraryPath "+rmb.getLibraryPath()); //libraryPath
MemoryMXBean mm=(MemoryMXBean)ManagementFactory.getMemoryMXBean();
System.out.println("getHeapMemoryUsage "+mm.getHeapMemoryUsage()); //堆内存
System.out.println("getNonHeapMemoryUsage "+mm.getNonHeapMemoryUsage()); //非堆内存
List<MemoryPoolMXBean> mpmList=ManagementFactory.getMemoryPoolMXBeans(); //内存详细信息 eden suviver old perm
for(MemoryPoolMXBean mpm:mpmList){
System.out.println("getUsage "+mpm.getName()+":"+mpm.getUsage());
}