Once this exception is thrown, is object that caused this thrown out of memory? Does it happen right away?
In other words, if i am adding objects to a list, at some point this can no longer happen and OOM error is thrown. At that time, does anything happen to the list itself?
java.lang.OutOfMemoryError: Java heap space
This is thrown when a new object could not be created. The current object will continue to exist.
However, due to the nature of an error like this the current code will stop executing and it’s likely that the current object will be garbage-collected soon. It just depends on the structure of your code and whether references are still being held to your object.