简体   繁体   English

Java内存不足错误

[英]Java OutOfMemory Error

I am seeing an OutOfMemory problem and I am not sure it is the PERM GEN area or the heap space. 我看到内存不足的问题,并且不确定是PERM GEN区域还是堆空间。 The error message does not say anything about which area ran out of memory. 该错误消息没有说明哪个区域内存不足。

Here is a partial stack trace: The following is information that may be useful to the developer of BETWEENNESS: java.lang.OutOfMemoryError at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.(ZipFile.java:127) at java.util.zip.ZipFile.(ZipFile.java:143) at com..util.internal.ZipFiles.unzip(ZipFiles.java:91) I looked at the heap space just before it ran out of memory using the jmap -heap command: 这是部分堆栈跟踪:以下是可能对BETWEENNESS开发人员有用的信息:java.util.zip.ZipFile.open(本机方法)处的java.lang.OutOfMemoryError(在java.util.zip.ZipFile。处(本机方法))( ZipFile.java:127)(位于java.util.zip.ZipFile。(ZipFile.java:143)位于com..util.internal.ZipFiles.unzip(ZipFiles.java:91))使用jmap -heap命令使内存不足:

 using thread-local object allocation.
 Parallel GC with 23 thread(s)

 Heap Configuration:
    MinHeapFreeRatio = 40
    MaxHeapFreeRatio = 70
    MaxHeapSize      = 31675383808 (30208.0MB)
    NewSize          = 1310720 (1.25MB)
    MaxNewSize       = 17592186044415 MB
    OldSize          = 5439488 (5.1875MB)
    NewRatio         = 2
    SurvivorRatio    = 8
    PermSize         = 21757952 (20.75MB)
    MaxPermSize      = 536870912 (512.0MB)

 Heap Usage:
 PS Young Generation
 Eden Space:
    capacity = 9762177024 (9309.9375MB)
    used     = 7286558512 (6949.003707885742MB)
    free     = 2475618512 (2360.933792114258MB)
    74.64071276403028% used
 From Space:
    capacity = 396230656 (377.875MB)
    used     = 340623360 (324.84375MB)
    free     = 55607296 (53.03125MB)
    85.96592788620576% used
 To Space:
    capacity = 398131200 (379.6875MB)
    used     = 0 (0.0MB)
    free     = 398131200 (379.6875MB)
    0.0% used
 PS Old Generation
    capacity = 1992163328 (1899.875MB)
    used     = 1455304512 (1387.8865356445312MB)
    free     = 536858816 (511.98846435546875MB)
    73.05146578825087% used
 PS Perm Generation
    capacity = 418578432 (399.1875MB)
    used     = 418567008 (399.1766052246094MB)
    free     = 11424 (0.010894775390625MB)
    99.99727076238844% used }

And also, I had supplied the following arguments to the JVM: -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/ but I do not see any heap. 而且,我向JVM提供了以下参数:-XX:+ HeapDumpOnOutOfMemoryError -XX:HeapDumpPath = / tmp /,但是我看不到任何堆。

My questions is why is the heap not being generated and how do I figure out which part of the JVm is getting full. 我的问题是为什么不生成堆,以及如何确定JVm的哪一部分已满。

Thanks. 谢谢。

Your provided information says, that your PermGen is 99% full. 您提供的信息表明,您的PermGen已满99%。 And your Heap is already 73% full. 而且您的堆已经满了73%。 So increasing both would not be bad at all. 因此,将两者都增加并不是一件坏事。

Further you could activate the garbage collector's logging with -XX:+PrintGCDetails to get detailed information on how your JVM is using memory. 此外,您可以使用-XX:+PrintGCDetails激活垃圾收集器的日志记录,以获取有关JVM如何使用内存的详细信息。 Additionally activate -XX:+PrintGCTimeStamps and -XX:+PrintGCDateStamps . 另外激活-XX:+PrintGCTimeStamps-XX:+PrintGCDateStamps -Xloggc:$filename sends the logs to a file, which you could easily analyze with something like IMB PMAT tool or GCViewer . -Xloggc:$filename将日志发送到文件,您可以使用IMB PMAT工具GCViewer之类的文件轻松对其进行分析。

Additionally you should consider using VisualVM to monitor your application while running. 另外,您应该考虑在运行时使用VisualVM监视应用程序。

Besides: A colleague of mine found a smart way to get a heapdump many times faster through gdb: 此外:我的一位同事发现了一种聪明的方法来通过gdb更快地获得堆转储:

cat > /tmp/dodump <<EOF
gcore jvm.core
detach
quit
EOF
time gdb --batch --command=/tmp/dodump --pid=`pgrep java`
jmap -dump:format=b,file=jvm.hprof `which java` jvm.core
rm jvm.core
gzip -9 jvm.hprof 

Source 资源

Credits go fully to him. 功劳全归他。

According to stack trace, OutOfMemoryError happens inside ZipFile.open() native method. 根据堆栈跟踪, OutOfMemoryError发生在ZipFile.open()本机方法内部。 This means that the problem has nothing to do with Java Heap size nor with PermGen. 这意味着该问题与Java堆大小或PermGen无关。 It is likely related with ZIP cache which is malloc'ed or mmap'ed internally by JDK library. 它可能与ZIP缓存有关,后者由JDK库在内部进行了malloc或mmap的处理。

Try adding -Dsun.zip.disableMemoryMapping=true JVM option to see if it helps. 尝试添加-Dsun.zip.disableMemoryMapping=true JVM选项,以查看是否有帮助。
How large is ZIP file being opened? ZIP文件打开了多少?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM