如何检查linux为jvm分配的堆大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9257361/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:32:50  来源:igfitidea点击:

how to check heap size allocated for jvm by linux

linuxtomcatjvmheap-memoryheap-size

提问by Amit

I have apache-tomcat as my web server. I want to check what heap size is allocated for jvm by linux. Also from where, I can modify it.

我有 apache-tomcat 作为我的网络服务器。我想检查 linux 为 jvm 分配的堆大小。同样从哪里,我可以修改它。

采纳答案by Kris

You can easily check the heap size memory allocation using JConsole, if you have a path to your jre/jdk set up correctly on the system you should be able to start it with command jconsolefrom anywhere.

您可以使用 JConsole 轻松检查堆大小内存分配,如果您在系统上正确设置了 jre/jdk 的路径,您应该能够jconsole从任何地方使用命令启动它。

For managing your heap memory allocation you can have a look here: http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html

要管理堆内存分配,您可以在这里查看:http: //javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html

回答by HonkyTonk

The heap size used by Tomcat is defined in its configuration.

Tomcat 使用的堆大小在其配置中定义。

This is the place where you can both check and change it.

这是您可以检查和更改它的地方。

If you're unsure about where this configuration is saved, I'd suggest looking at the Tomcat documentation where this is explained together with all configuration values.

如果您不确定此配置的保存位置,我建议您查看 Tomcat 文档,其中解释了所有配置值。

回答by Derick

A simple way on Linux is to run the following:

在 Linux 上的一个简单方法是运行以下命令:

ps -ef |grep tomcat

Look for the starting and maximum JVM memory:

查找起始和最大 JVM 内存:

-Xms1024m -Xmx4096m

-Xms1024m -Xmx4096m

In this case it is allocating 1Gon startup and the Maximum is 4G.

在这种情况下,它在启动时分配1G并且最大值是4G

回答by TheFiddlerWins

If you need more information from the server but cannot log into it interactively (or don't have a GUI or JMX set up etc) you can include javamelodyin your POM file/libs and it will create a page at host:8080//monitoring with all kinds of good information, including heap size, GC statistics and permgen size.

如果您需要来自服务器的更多信息但无法以交互方式登录(或没有设置 GUI 或 JMX 等),您可以在 POM 文件/库中包含javamelody,它将在主机:8080 上创建一个页面//使用各种好的信息进行监控,包括堆大小、GC 统计信息和 permgen 大小。

This is NOT a safe thing to leave running in a production environment - if you need it all the time at least lock it down!

在生产环境中运行并不是一件安全的事情 - 如果您一直需要它,至少将其锁定!