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?
The Java Machine Specification states in section 6.3 (emphasis mine):
OutOfMemoryError: The Java virtual machine implementation has run out of either virtual or physical memory, and the automatic storage manager was unable to reclaim enough memory to satisfy an object creation request.
So the JVM does give a guarantee that it will try what it can to free up memory through garbage collection before it throws an OOME.