Error java.lang.OutOfMemoryError: GC overhead limit exceeded

后端 未结 20 2363
攒了一身酷
攒了一身酷 2020-11-21 05:23

I get this error message as I execute my JUnit tests:

java.lang.OutOfMemoryError: GC overhead limit exceeded

I know what an OutOfMemo

20条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-21 05:34

    Java heap size descriptions (xms, xmx, xmn)

    -Xms size in bytes
    
    Example : java -Xms32m
    

    Sets the initial size of the Java heap. The default size is 2097152 (2MB). The values must be a multiple of, and greater than, 1024 bytes (1KB). (The -server flag increases the default size to 32M.)

    -Xmn size in bytes
    
    Example : java -Xmx2m
    

    Sets the initial Java heap size for the Eden generation. The default value is 640K. (The -server flag increases the default size to 2M.)

    -Xmx size in bytes
    
    Example : java -Xmx2048m
    

    Sets the maximum size to which the Java heap can grow. The default size is 64M. (The -server flag increases the default size to 128M.) The maximum heap limit is about 2 GB (2048MB).

    Java memory arguments (xms, xmx, xmn) formatting

    When setting the Java heap size, you should specify your memory argument using one of the letters “m” or “M” for MB, or “g” or “G” for GB. Your setting won’t work if you specify “MB” or “GB.” Valid arguments look like this:

    -Xms64m or -Xms64M -Xmx1g or -Xmx1G Can also use 2048MB to specify 2GB Also, make sure you just use whole numbers when specifying your arguments. Using -Xmx512m is a valid option, but -Xmx0.5g will cause an error.

    This reference can be helpful for someone.

提交回复
热议问题