MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
System.out.println(mbean.getHeapMemoryUsage().toString();
System.out.println(mbean.getNonHeapMemoryUsage().toString();
will print out
MemoryMXBean is also able to send out notification when some memory usage threshold is met.
init = 0(0K) used = 319360(311K) committed = 2031616(1984K) max = 66650112(65088K)
init = 8585216(8384K) used = 2379416(2323K) committed = 8880128(8672K) max = 100663296(98304K)
No comments:
Post a Comment