GC (Allocation Failure) VS OutOfMemoryError Exception

后端 未结 2 593
栀梦
栀梦 2021-01-05 04:24

\'OutOfMemoryError\': Usually, this error is thrown when there is insufficient space to allocate an object in the Java heap.

GC (Allocation Failure): Allocation Fail

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-05 05:07

    In general, an OutOfMemoryError occurs when you have exceeded the maximum memory you have already allocated to the JVM. This amount can be changed when starting java using jvm parameters. e.g. -Xmx2G. Note that this amount isn't used immediately. See below.

    GC (Allocation Failure) is similar, except it occurs when the garbage collector runs out of memory on the heap, and it attempts to allocate more. If your allocated memory is higher than your available system memory, this will fail. Essentially, the JVM tries to allocate memory which isn't there.

    See for more information

提交回复
热议问题