Given a heapdump or a running VM, how do I discover what the contents of the permanent generation is ? I know about 'jmap -permstat' but that's not available on Windows.
给定堆转储或正在运行的VM,如何发现永久代的内容是什么?我知道'jmap -permstat'但是在Windows上不可用。
8 个解决方案
#1
1
This article Memory Monitoring with Java SE 5 describes how to programmatically discover information on heap usage, memory pools (including permgen space) and so on. Its very simple:
本文使用Java SE 5进行内存监视介绍了如何以编程方式发现有关堆使用情况,内存池(包括permgen空间)等的信息。它非常简单:
MemoryUsage usage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
long nonHeapFree = usage.getMax() - usage.getUsed();
long nonHeapTotal = usage.getMax();
In my testing on OSX (Sun VM) "non heap memory usage" matches the values returned for the permgen pool closely and presumably will do something useful on VMs that don't have permgen.
在我对OSX(Sun VM)的测试中,“非堆内存使用”与permgen池返回的值相匹配,并且可能会对没有permgen的VM执行一些有用的操作。
#2
1
The permanent generation contains the class object. So you should check the heap dump or other form of object list for classes. If you have problem with the size of permanent generation usually it is caused by two reason:
永久代包含类对象。因此,您应该检查堆转储或其他形式的对象列表。如果你对永久代的大小有问题,通常是由两个原因造成的:
- your program or a library you use creates classes dynamically and the default size of permanent generation is too small - simple increate the size with -XX:MaxPermSize=256m
- your program or a library you use creates new classes dynamically every time it is called, so the size of permanent generation increases non-stop - this is a programming error you should fix it (or search a fix/create a bug report)
您使用的程序或库动态创建类,永久生成的默认大小太小 - 使用-XX简单地增加大小:MaxPermSize = 256m
您使用的程序或库每次调用时都会动态创建新类,因此永久生成的大小不停增加 - 这是一个编程错误,您应该修复它(或搜索修复/创建错误报告)
To see which is your case check the size of the permanent generation over a larger period.
要查看您的情况,请检查更长时间内永久代的大小。
And a good overview about permanent generation:
关于永久性发电的一个很好的概述:
http://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_generation
#3
0
See my blog post about thr permsize of Eclipse
请参阅我关于Eclipse的thr permsize的博客文章
In short the Memory Analyzer can doit, but you need the SAP JVM.
简而言之,Memory Analyzer可以做,但您需要SAP JVM。
#4
0
Do you have a specific problem to solve? The use of String.intern() is one of the typical causes for permgen problems. Additionally projects with a lot of classes also have permgen problems.
您有具体问题需要解决吗? String.intern()的使用是permgen问题的典型原因之一。此外,有很多课程的项目也存在permgen问题。
I do not know how to get into the permgen and see what it is there...
我不知道如何进入permgen,看看它是什么......
#5
0
Permanent generation really only contains two kinds of things: Class definitions and interned strings. Latter very rarely gives you problems, but it is often blamed for problems. More often former is the one giving problems, due to code generation and partial hot reloading (dangling references).
永久生成实际上只包含两种内容:类定义和实习字符串。后期很少给你带来问题,但它常常被归咎于问题。由于代码生成和部分热重新加载(悬空引用),更常见的是前者产生问题。
Unlike name suggests, permgen does eventually get GC'ed too, just not part of regular GC cycle. Hence unreferenced interned Strings and unused classes do get cleaned up. But permgen also does not grow dynamically which means that it is sometimes necessary to manually resize its settings for JVM start.
与名称不同,permgen最终也会得到GC,而不是常规GC循环的一部分。因此,未引用的实习字符串和未使用的类确实得到清理。但是permgen也没有动态增长,这意味着有时需要手动调整其JVM启动的设置。
#6
0
I'm looking into the same thing but due to memory constraints of an embedded platform.
我正在研究同样的事情,但由于嵌入式平台的内存限制。
Look at the code for jmap, the permstat tool is only available if the sun.jvm.hotspot.tools.HeapSummary class is available. This class is part of the serviceability agent. According to OpenJDK documentation (http://openjdk.java.net/groups/serviceability/svcjdk.html#bsa):
查看jmap的代码,permstat工具仅在sun.jvm.hotspot.tools.HeapSummary类可用时才可用。此类是可维护性代理的一部分。根据OpenJDK文档(http://openjdk.java.net/groups/serviceability/svcjdk.html#bsa):
Serviceability Agent components are built as part of the standard build of the HotSpot repository. These components are:
可维护性代理组件是作为HotSpot存储库的标准版本的一部分构建的。这些组件是:
-libsaproc.so: this is the native code component of SA.
-libsaproc.so:这是SA的本机代码组件。
-sa-jdi.jar: This is contains the Java classes of SA. It includes an implementation of JDI which allows JDI clients to do read-only debugging on core files and hung processes.
-sa-jdi.jar:这包含SA的Java类。它包括一个JDI实现,它允许JDI客户端对核心文件和挂起进程进行只读调试。
SA is used by jinfo, jmap, jstack
SA由jinfo,jmap,jstack使用
NOTE: The Serviceability Agent and the technologies that use it are not currently included in JDK releases on the Windows platforms.
注意:Serviceability Agent及其使用的技术当前未包含在Windows平台上的JDK版本中。
Looks to be the case for Oracle JDK as well. I'm looking to modify the jmap tool to get more info.
看起来也是Oracle JDK的情况。我想修改jmap工具以获取更多信息。
#7
0
One technique that helped me was to use the -verbose:class
command-line option to java, and you'll get log output telling you as classes are loaded/unloaded. Since classes are loaded to the permgen, this can help in certain circumstances.
帮助我的一种技术是对java使用-verbose:class命令行选项,并且您将获得日志输出,告诉您何时加载/卸载类。由于类被加载到permgen,这在某些情况下会有所帮助。
#8
-1
you can use JConsole or jvisualvm.exe(with jdk 1.6 7) to find what is where. If you want to know how all of your objects are related to each other and tree of objects, then you might want to try Eclipse Memory Analyzer -- http://www.eclipse.org/mat/.
您可以使用JConsole或jvisualvm.exe(使用jdk 1.6 7)来查找其中的内容。如果您想知道所有对象如何相互关联以及对象树,那么您可能想要尝试Eclipse Memory Analyzer - http://www.eclipse.org/mat/。
IN summary, you will get want you want from "http://www.eclipse.org/mat/".
总之,你会想要你想要的“http://www.eclipse.org/mat/”。
Good luck,
#1
1
This article Memory Monitoring with Java SE 5 describes how to programmatically discover information on heap usage, memory pools (including permgen space) and so on. Its very simple:
本文使用Java SE 5进行内存监视介绍了如何以编程方式发现有关堆使用情况,内存池(包括permgen空间)等的信息。它非常简单:
MemoryUsage usage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
long nonHeapFree = usage.getMax() - usage.getUsed();
long nonHeapTotal = usage.getMax();
In my testing on OSX (Sun VM) "non heap memory usage" matches the values returned for the permgen pool closely and presumably will do something useful on VMs that don't have permgen.
在我对OSX(Sun VM)的测试中,“非堆内存使用”与permgen池返回的值相匹配,并且可能会对没有permgen的VM执行一些有用的操作。
#2
1
The permanent generation contains the class object. So you should check the heap dump or other form of object list for classes. If you have problem with the size of permanent generation usually it is caused by two reason:
永久代包含类对象。因此,您应该检查堆转储或其他形式的对象列表。如果你对永久代的大小有问题,通常是由两个原因造成的:
- your program or a library you use creates classes dynamically and the default size of permanent generation is too small - simple increate the size with -XX:MaxPermSize=256m
- your program or a library you use creates new classes dynamically every time it is called, so the size of permanent generation increases non-stop - this is a programming error you should fix it (or search a fix/create a bug report)
您使用的程序或库动态创建类,永久生成的默认大小太小 - 使用-XX简单地增加大小:MaxPermSize = 256m
您使用的程序或库每次调用时都会动态创建新类,因此永久生成的大小不停增加 - 这是一个编程错误,您应该修复它(或搜索修复/创建错误报告)
To see which is your case check the size of the permanent generation over a larger period.
要查看您的情况,请检查更长时间内永久代的大小。
And a good overview about permanent generation:
关于永久性发电的一个很好的概述:
http://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_generation
#3
0
See my blog post about thr permsize of Eclipse
请参阅我关于Eclipse的thr permsize的博客文章
In short the Memory Analyzer can doit, but you need the SAP JVM.
简而言之,Memory Analyzer可以做,但您需要SAP JVM。
#4
0
Do you have a specific problem to solve? The use of String.intern() is one of the typical causes for permgen problems. Additionally projects with a lot of classes also have permgen problems.
您有具体问题需要解决吗? String.intern()的使用是permgen问题的典型原因之一。此外,有很多课程的项目也存在permgen问题。
I do not know how to get into the permgen and see what it is there...
我不知道如何进入permgen,看看它是什么......
#5
0
Permanent generation really only contains two kinds of things: Class definitions and interned strings. Latter very rarely gives you problems, but it is often blamed for problems. More often former is the one giving problems, due to code generation and partial hot reloading (dangling references).
永久生成实际上只包含两种内容:类定义和实习字符串。后期很少给你带来问题,但它常常被归咎于问题。由于代码生成和部分热重新加载(悬空引用),更常见的是前者产生问题。
Unlike name suggests, permgen does eventually get GC'ed too, just not part of regular GC cycle. Hence unreferenced interned Strings and unused classes do get cleaned up. But permgen also does not grow dynamically which means that it is sometimes necessary to manually resize its settings for JVM start.
与名称不同,permgen最终也会得到GC,而不是常规GC循环的一部分。因此,未引用的实习字符串和未使用的类确实得到清理。但是permgen也没有动态增长,这意味着有时需要手动调整其JVM启动的设置。
#6
0
I'm looking into the same thing but due to memory constraints of an embedded platform.
我正在研究同样的事情,但由于嵌入式平台的内存限制。
Look at the code for jmap, the permstat tool is only available if the sun.jvm.hotspot.tools.HeapSummary class is available. This class is part of the serviceability agent. According to OpenJDK documentation (http://openjdk.java.net/groups/serviceability/svcjdk.html#bsa):
查看jmap的代码,permstat工具仅在sun.jvm.hotspot.tools.HeapSummary类可用时才可用。此类是可维护性代理的一部分。根据OpenJDK文档(http://openjdk.java.net/groups/serviceability/svcjdk.html#bsa):
Serviceability Agent components are built as part of the standard build of the HotSpot repository. These components are:
可维护性代理组件是作为HotSpot存储库的标准版本的一部分构建的。这些组件是:
-libsaproc.so: this is the native code component of SA.
-libsaproc.so:这是SA的本机代码组件。
-sa-jdi.jar: This is contains the Java classes of SA. It includes an implementation of JDI which allows JDI clients to do read-only debugging on core files and hung processes.
-sa-jdi.jar:这包含SA的Java类。它包括一个JDI实现,它允许JDI客户端对核心文件和挂起进程进行只读调试。
SA is used by jinfo, jmap, jstack
SA由jinfo,jmap,jstack使用
NOTE: The Serviceability Agent and the technologies that use it are not currently included in JDK releases on the Windows platforms.
注意:Serviceability Agent及其使用的技术当前未包含在Windows平台上的JDK版本中。
Looks to be the case for Oracle JDK as well. I'm looking to modify the jmap tool to get more info.
看起来也是Oracle JDK的情况。我想修改jmap工具以获取更多信息。
#7
0
One technique that helped me was to use the -verbose:class
command-line option to java, and you'll get log output telling you as classes are loaded/unloaded. Since classes are loaded to the permgen, this can help in certain circumstances.
帮助我的一种技术是对java使用-verbose:class命令行选项,并且您将获得日志输出,告诉您何时加载/卸载类。由于类被加载到permgen,这在某些情况下会有所帮助。
#8
-1
you can use JConsole or jvisualvm.exe(with jdk 1.6 7) to find what is where. If you want to know how all of your objects are related to each other and tree of objects, then you might want to try Eclipse Memory Analyzer -- http://www.eclipse.org/mat/.
您可以使用JConsole或jvisualvm.exe(使用jdk 1.6 7)来查找其中的内容。如果您想知道所有对象如何相互关联以及对象树,那么您可能想要尝试Eclipse Memory Analyzer - http://www.eclipse.org/mat/。
IN summary, you will get want you want from "http://www.eclipse.org/mat/".
总之,你会想要你想要的“http://www.eclipse.org/mat/”。
Good luck,