使用 jmap 查找当前堆大小
我想知道 Java 进程在某个时间使用的总堆大小是多少,我必须使用 jmap
。
jmap -heap
的输出给了我这样的信息:
Attaching to process ID 2899, please wait... Debugger attached successfully. Server compiler detected. JVM version is 14.2-b01 using thread-local object allocation. Parallel GC with 2 thread(s) Heap Configuration: MinHeapFreeRatio = 40 MaxHeapFreeRatio = 70 MaxHeapSize = 1258291200 (1200.0MB) NewSize = 1048576 (1.0MB) MaxNewSize = 4294901760 (4095.9375MB) OldSize = 4194304 (4.0MB) NewRatio = 8 SurvivorRatio = 8 PermSize = 16777216 (16.0MB) MaxPermSize = 67108864 (64.0MB) Heap Usage: PS Young Generation Eden Space: capacity = 119013376 (113.5MB) used = 117277608 (111.84464263916016MB) free = 1735768 (1.6553573608398438MB) 98.54153536489882% used From Space: capacity = 131072 (0.125MB) used = 81920 (0.078125MB) free = 49152 (0.046875MB) 62.5% used To Space: capacity = 131072 (0.125MB) used = 0 (0.0MB) free = 131072 (0.125MB) 0.0% used PS Old Generation capacity = 954466304 (910.25MB) used = 80791792 (77.04905700683594MB) free = 873674512 (833.2009429931641MB) 8.46460390077846% used PS Perm Generation capacity = 57671680 (55.0MB) used = 41699008 (39.76727294921875MB) free = 15972672 (15.23272705078125MB) 72.30413263494319% used
我可以使用这些值的公式来找出使用的总内存吗?
欢迎其他关于如何在 Linux 上找到这一点的建议,但 jmap
优于它们。
谢谢
I would like to find out what is the total heap size that is in use at a certain time by a Java process and I have to use jmap
.
The output of jmap -heap <pid>
gives me something like this:
Attaching to process ID 2899, please wait... Debugger attached successfully. Server compiler detected. JVM version is 14.2-b01 using thread-local object allocation. Parallel GC with 2 thread(s) Heap Configuration: MinHeapFreeRatio = 40 MaxHeapFreeRatio = 70 MaxHeapSize = 1258291200 (1200.0MB) NewSize = 1048576 (1.0MB) MaxNewSize = 4294901760 (4095.9375MB) OldSize = 4194304 (4.0MB) NewRatio = 8 SurvivorRatio = 8 PermSize = 16777216 (16.0MB) MaxPermSize = 67108864 (64.0MB) Heap Usage: PS Young Generation Eden Space: capacity = 119013376 (113.5MB) used = 117277608 (111.84464263916016MB) free = 1735768 (1.6553573608398438MB) 98.54153536489882% used From Space: capacity = 131072 (0.125MB) used = 81920 (0.078125MB) free = 49152 (0.046875MB) 62.5% used To Space: capacity = 131072 (0.125MB) used = 0 (0.0MB) free = 131072 (0.125MB) 0.0% used PS Old Generation capacity = 954466304 (910.25MB) used = 80791792 (77.04905700683594MB) free = 873674512 (833.2009429931641MB) 8.46460390077846% used PS Perm Generation capacity = 57671680 (55.0MB) used = 41699008 (39.76727294921875MB) free = 15972672 (15.23272705078125MB) 72.30413263494319% used
Can I use a formula for these values to find out total memory used?
Other suggestions on how can I find this out on Linux are welcome but jmap
is preferred over them.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您尝试与主窗口显示“总堆使用情况”的
jconsole
或jvisualvm
进行比较,我发现通过添加“已使用的伊甸园空间”和“已使用” ps 老一代空间' 我得到了与上述程序中该图表显示的内容相当的内容 - 这就是我现在倾向于继续进行的内容。if you are trying to compare to something like
jconsole
orjvisualvm
with the main window displaying 'total heap usage' I found out that by adding 'used eden space' and 'used ps old generation space' I got the equivalent of what that graph shows in the aforementioned programs -- that's what I tend to go on now.堆使用情况:
下的条目列出了 JVM 中的各种分区内存池,以及它们的最大大小、已用空间和可用空间。您可以将各种used:
值相加,这将为您提供总内存使用量的合理值,尽管可能存在一些未在列出的池中考虑的 JVM 开销。The entries under
Heap Usage:
are listing the various partitioned memory pools in the JVM, along with their max size, used and free space. You could just add up the variousused:
values, that should give you a sensible value for the total memory usage, although there may be some JVM overhead that's not accounted for in the listed pools.