Java:如何检查当前 Perm / PermGen 大小?

发布于 2024-09-19 18:33:47 字数 501 浏览 7 评论 0原文

昨天,当我运行 WebLogic Application Server 11g 安装程序时,遇到了 OutOfMemory 错误,因此我在 Google 上搜索了答案:

java -Xms256m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m -jar wls1032_generic.jar

一切正常:)

但是,当我仔细考虑解决方案时,我可能犯了一个错误:我怎么知道目前的设置有那些?我当然需要在覆盖它们之前检查它们的值,对吧?

有什么想法吗?

相关链接:中的人员SO 上的另一个线程建议尝试和错误方法,这并不理想。

非常感谢。

Yesterday when I was running the WebLogic Application Server 11g installer, I encountered a OutOfMemory error, so I Googled for the answer:

java -Xms256m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m -jar wls1032_generic.jar

Everything worked :)

However, when I think twice about the solution, I might have made a mistake: How could I know the current settings of those? I certainly need to check their values before overriding them, right?

Any thoughts?

Related link: People in another thread on SO suggested trial and error approach, which is not ideal.

Many thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

苍白女子 2024-09-26 18:33:47

您可以使用 jinfo.exe 实用程序检查正在运行的 JVM 的任何 JVM 标志的值。

%JAVA_HOME%\bin\jinfo.exe -flag;

因此,要检查 -XX:PermSize JVM 选项的值,您可以运行

%JAVA_HOME%\bin\jinfo.exe -flag PermSize< /代码>

You can check the values of any JVM flags of a running JVM by using the jinfo.exe utility.

%JAVA_HOME%\bin\jinfo.exe -flag <flagName> <pid>

so to check the value of -XX:PermSize JVM option you can run

%JAVA_HOME%\bin\jinfo.exe -flag PermSize <pid>

不即不离 2024-09-26 18:33:47

您可以在此处使用jmap,它是 JVM 堆转储工具。

例如:

jmap -heap 5900

会打印:

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 989855744 (944.0MB)
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 17592186044415 MB
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 21757952 (20.75MB)
   MaxPermSize      = 85983232 (82.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 242352128 (231.125MB)
   used     = 9196056 (8.770042419433594MB)
   free     = 233156072 (222.3549575805664MB)
   3.79450185805672% used
From Space:
   capacity = 41877504 (39.9375MB)
   used     = 0 (0.0MB)
   free     = 41877504 (39.9375MB)
   0.0% used
To Space:
   capacity = 42663936 (40.6875MB)
   used     = 0 (0.0MB)
   free     = 42663936 (40.6875MB)
   0.0% used
PS Old Generation
   capacity = 80609280 (76.875MB)
   used     = 34187936 (32.604156494140625MB)
   free     = 46421344 (44.270843505859375MB)
   42.41191088668699% used
PS Perm Generation
   capacity = 85393408 (81.4375MB)
   used     = 63472624 (60.53221130371094MB)
   free     = 21920784 (20.905288696289062MB)
   74.32965317416539% used

It gets内存信息(包括PermGen)。5900是Java的进程id。

You can use jmap at here, it's JVM Heap Dump Tool.

for example:

jmap -heap 5900

It will print:

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 989855744 (944.0MB)
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 17592186044415 MB
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 21757952 (20.75MB)
   MaxPermSize      = 85983232 (82.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 242352128 (231.125MB)
   used     = 9196056 (8.770042419433594MB)
   free     = 233156072 (222.3549575805664MB)
   3.79450185805672% used
From Space:
   capacity = 41877504 (39.9375MB)
   used     = 0 (0.0MB)
   free     = 41877504 (39.9375MB)
   0.0% used
To Space:
   capacity = 42663936 (40.6875MB)
   used     = 0 (0.0MB)
   free     = 42663936 (40.6875MB)
   0.0% used
PS Old Generation
   capacity = 80609280 (76.875MB)
   used     = 34187936 (32.604156494140625MB)
   free     = 46421344 (44.270843505859375MB)
   42.41191088668699% used
PS Perm Generation
   capacity = 85393408 (81.4375MB)
   used     = 63472624 (60.53221130371094MB)
   free     = 21920784 (20.905288696289062MB)
   74.32965317416539% used

It gets memory information (including PermGen).5900 is the process id of Java.

混浊又暗下来 2024-09-26 18:33:47

您可以使用 VisualVM 之类的东西, http://java.dzone.com/articles/best-kept-secret-jdk-visualvm&default=false&zid=159&browser=16&mid=0&refresh= 0,监视您的内存使用情况,您将看到其峰值的最大值,并且它将为您提供有关内存的哪一部分实际上已满的具体信息,以便您可以更好地优化您的环境。

您可能会发现您没有想到的内存的某些部分实际上已被填满,通过监视它您可以看到需要做什么才能获得更好的性能。

You can use something like VisualVM, http://java.dzone.com/articles/best-kept-secret-jdk-visualvm&default=false&zid=159&browser=16&mid=0&refresh=0, to monitor your memory usage and you will see the max by where it peaks, and it will give you specific info as to which part of memory is actually full, so you can better optimize your environment.

You may find that some part of memory that you don't think about is actually filling up, and by monitoring it you can see what you need to do to get better performance.

¢好甜 2024-09-26 18:33:47

另一种获取 PermGen 信息的方法是:

kill -3 JAVA_PID

获取线程转储和内存信息(包括 PermGen)。示例输出:

PSPermGen       total 68864K, used 68808K [0x000000009c600000, 0x00000000a0940000, 0x00000000a1800000)

由于某种原因,jinfo 在我需要时不起作用。它返回:

Unable to open socket file: target process not responding or HotSpot VM not loaded

上述情况的可能原因很少,其中之一可能是 java.io.tmpdir 的显式声明,如 https ://www.permeance.com.au/web/terry.mueller/home/-/blogs/unable-to-open-socket-file-target-process-not-responding-or-hotspot-vm-not-loaded

Another way to get PermGen information is:

kill -3 JAVA_PID

It gets thread dump and memory information (including PermGen). Example output:

PSPermGen       total 68864K, used 68808K [0x000000009c600000, 0x00000000a0940000, 0x00000000a1800000)

For some reason jinfo did not work when I needed it. It returned:

Unable to open socket file: target process not responding or HotSpot VM not loaded

There are few possible causes of the above and one of them may be explicit declaration of the java.io.tmpdir as described at https://www.permeance.com.au/web/terry.mueller/home/-/blogs/unable-to-open-socket-file-target-process-not-responding-or-hotspot-vm-not-loaded

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文