In case the heap is full, the JVM throws an
OutOfMemoryError
. But is it assured that a (full) garbage collection always takes place before such an exception is thrown?
This would mean that the memory is full only with strong referenced objects (or reachable by GC Roots) when the exception is thrown.
Edit: Assume the Sun JVM - HotSpot is in discussion.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…