GC(分配失败)VS OutOfMemoryError异常 [英] GC (Allocation Failure) VS OutOfMemoryError Exception

查看:133
本文介绍了GC(分配失败)VS OutOfMemoryError异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

'OutOfMemoryError': 通常,当Java堆中没有足够的空间来分配对象时,就会引发此错误.

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

GC(分配失败): 分配失败"表示存在一个分配请求,该请求大于年轻一代中的可用空间.

GC (Allocation Failure): Allocation Failure" means that there is an allocation request that is bigger than the available space in young generation.

这是否意味着当年轻代内存已满(次要GC)并且在完全GC中抛出"OutOfMemoryError"时,将引发分配失败?

Does this mean Allocation Failure will be thrown when Young generation memory is full (Minor GC) and "OutOfMemoryError" is thrown in full GC?

推荐答案

这些可以成为关联.但是它们是完全不同的东西.

These could become related as far as I can tell; but they are entirely different things.

OutOfMemory是您无法从中恢复的错误-JVM将在此时死亡.

OutOfMemory is an error you can not recover from - the JVM will die at this point.

GC (Allocation Failure): Allocation Failure是GC启动(并进行次要回收)的原因.此时可能会发生一些事情,例如:释放了足够的空间以使新分配适合young generation.或没有发生,某些对象将被提升为old generation.如果can't be promoted,可能会触发full GC-如果释放的空间不足,则会抛出OutOfMemory 可能.

GC (Allocation Failure): Allocation Failure is the reason why GC will kick in (and do a minor collection). At this point some things might happen, like: enough space is freed for the new allocation to fit into young generation. Or that did not happen and some objects will be promoted to the old generation. If they can't be promoted, a full GC might be triggered - and if that does not free enough space an OutOfMemory might be thrown.

这篇关于GC(分配失败)VS OutOfMemoryError异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆