Generate java dump when OutOfMemory

前端 未结 3 1120
难免孤独
难免孤独 2021-01-05 05:34

I have a program that should eventually generate OutOfMemory . The program code is:

public class VeryLargeObject implements Serializable {
    p         


        
相关标签:
3条回答
  • 2021-01-05 05:49

    For starter drop the XX options and any options BEFORE VeryLargeObject, otherwise you pass the parameters to the java program and not the JVM

    0 讨论(0)
  • 2021-01-05 06:04

    The problem is that -XX:HeapDumpPath spefies a file and not a path.

    -Xms1024m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="c:\temp\dump2.hprof"
    

    added:

    and bestsss is right too, so you need to fix both "errors":

    java -Xms1024m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="c:\temp\dump2.hprof" VeryLargeObject
    
    0 讨论(0)
  • 2021-01-05 06:04

    I suspect the jvm could not write to the path and fails silently. For example, this has to be a file name in a directory which exists. If you have a directory D:\workspace it will fail. If you have D:\workspace\heap.hprof it may work. Try creating a blank file of that name first to see you can do this.

    0 讨论(0)
提交回复
热议问题