用于查找Java堆大小和内存的命令行工具(Linux)? [英] Command-line Tool to find Java Heap Size and Memory Used (Linux)?

查看:690
本文介绍了用于查找Java堆大小和内存的命令行工具(Linux)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个命令行工具(Linux)来检查Java应用程序的堆大小(和已用内存)?

Is there a Command-line Tool (Linux) to check Heap Size (and Used Memory) of a Java Application?

我已经尝试过jmap。但它提供了信息。关于内部记忆区域,如Eden / PermGen等,这对我没用。

I have tried jmap. But it gives info. about internal memory areas like Eden/PermGen etc., which is not useful to me.

我正在寻找类似的东西:

最大内存:1GB

最小内存:256 MB

堆内存:700 MB

已用内存:460 MB

I am looking for something like:
Max Memory: 1GB
Min Memory: 256 MB
Heap Memory: 700 MB
Used Memory: 460 MB

多数。我知道我可以在JConsole等中看到这个,但是我需要一个命令行工具(不能启用JMX等)。

Thats all. I know i can see this in JConsole etc., but i need a command-line tool (cannot enable JMX etc.)

任何这样的工具/命令?

Any such tool/command?

推荐答案

每个Java进程都有一个 pid ,您首先需要找到它 jps 命令。

Each Java process has a pid, which you first need to find with the jps command.

获得pid后,您可以使用 jstat -gc [insert-pid-here] 查找统计信息垃圾收集堆的行为。

Once you have the pid, you can use jstat -gc [insert-pid-here] to find statistics of the behavior of the garbage collected heap.


  • jstat -gccapacity [insert-pid-here] 将显示有关内存池生成和空间功能的信息。

  • jstat -gccapacity [insert-pid-here] will present information about memory pool generation and space capabilities.

jstat -gcutil [insert-pid-这里] 将显示每一代的利用率作为其容量的百分比。有用了一目了然的使用情况。

jstat -gcutil [insert-pid-here] will present the utilization of each generation as a percentage of its capacity. Useful to get an at a glance view of usage.

参见 jstat docs

这篇关于用于查找Java堆大小和内存的命令行工具(Linux)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆