Strategy for debugging surefire “The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?”

后端 未结 11 858
野的像风
野的像风 2020-12-05 02:11

I am working on a rather complex java project with many dependencies and many unit tests.

I am using java 1.6.0_65 on mac (mavericks) with maven 3.0.5 with maven-sur

11条回答
  •  我在风中等你
    2020-12-05 02:48

    JVM options that can help:

    -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=c:/dumps/
    

    Note: You can use forward slashes.
    Note 2: Make sure the folder exists and that the process has write permission. On recent windows systems, C:\ is write protected.
    Note 3: Make sure you have enough free space to write the dump. The Java 9 documentation mentions that the system's temp folder will be used when the disk is full.

    If there is no dump file, then you JVM didn't run out of memory.

    The next option is -XX:ErrorFile= which allows to the JVM to log fatal errors.

    -XX:+ShowMessageBoxOnError shows an error dialog if the JVM crashes.

    Note: You can change the flags of a running JVM using the jinfo command.

    Pass these options to Maven Surefire via the argLine option:

    
        
            
                maven-surefire-plugin
                
                    
                    @{argLine} -XX:+HeapDumpOnOutOfMemoryError -Xmx1g -XX:HeapDumpPath=H:/dumps/ -XX:ErrorFile=H:/dumps/ -XX:+ShowMessageBoxOnError
                
            
        
    
    

    The strange @{argLine} at the beginning allows other plugins like Jacoco to inject their options. For this to work, you need to add an empty property:

    
         
    
    

    You can verify that it works when the error happens: Maven will then dump the whole command line used to start the forked JVM.

提交回复
热议问题