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?
There's no guaranty that the last operation preceding OutOfMemoryError is garbage collection. Most probably not, since garbage collection would reduce the amount of used memory not increase it.