是否可以按池检查堆内存使用情况?
Is it possible to check heap memory usage by pool?
我一直致力于优化一个有很多内存泄漏问题的程序。泄漏现在已经消失,但主要 GC 的偶尔运行仍然对 PS 老一代产生了很大的影响。我知道我可以通过运行时检查基本的整体内存信息,但是是否可以从程序中检查 PS eden、PS survivor 和 PS old 中的使用情况?
jstat 工具 - Java Virtual Machine Statistics Monitoring Tool 是用来监控 JVM 使用情况的东西。
请完成此 link:
这个article可以帮到你
您可以编写自定义代码来分析内存,输出格式为
collection time: 82037
collection count: 116
PS Survivor Space: init = 1703936(1664K) used = 65536(64K) committed = 32047104(31296K) max = 32047104(31296K)
PS Eden Space: init = 10551296(10304K) used = 0(0K) committed = 69795840(68160K) max = 113049600(110400K)
PS Old Gen: init = 27983872(27328K) used = 239432344(233820K) committed = 357957632(349568K) max = 357957632(349568K)
Code Cache: init = 2555904(2496K) used = 19949568(19482K) committed = 20185088(19712K) max = 50331648(49152K)
PS Perm Gen: init = 21757952(21248K) used = 148450536(144971K) committed = 155058176(151424K) max = 268435456(262144K)
好read
您可以使用运行时 class 获取堆内存详细信息。
public class GetHeapMemory {
public static void main(String[] args) {
System.out.println(Runtime.getRuntime().freeMemory());
System.out.println(Runtime.getRuntime().maxMemory());
System.out.println(Runtime.getRuntime().totalMemory());
}
}
我一直致力于优化一个有很多内存泄漏问题的程序。泄漏现在已经消失,但主要 GC 的偶尔运行仍然对 PS 老一代产生了很大的影响。我知道我可以通过运行时检查基本的整体内存信息,但是是否可以从程序中检查 PS eden、PS survivor 和 PS old 中的使用情况?
jstat 工具 - Java Virtual Machine Statistics Monitoring Tool 是用来监控 JVM 使用情况的东西。
请完成此 link:
这个article可以帮到你
您可以编写自定义代码来分析内存,输出格式为
collection time: 82037
collection count: 116
PS Survivor Space: init = 1703936(1664K) used = 65536(64K) committed = 32047104(31296K) max = 32047104(31296K)
PS Eden Space: init = 10551296(10304K) used = 0(0K) committed = 69795840(68160K) max = 113049600(110400K)
PS Old Gen: init = 27983872(27328K) used = 239432344(233820K) committed = 357957632(349568K) max = 357957632(349568K)
Code Cache: init = 2555904(2496K) used = 19949568(19482K) committed = 20185088(19712K) max = 50331648(49152K)
PS Perm Gen: init = 21757952(21248K) used = 148450536(144971K) committed = 155058176(151424K) max = 268435456(262144K)
好read
您可以使用运行时 class 获取堆内存详细信息。
public class GetHeapMemory {
public static void main(String[] args) {
System.out.println(Runtime.getRuntime().freeMemory());
System.out.println(Runtime.getRuntime().maxMemory());
System.out.println(Runtime.getRuntime().totalMemory());
}
}