SoftReferences and java.lang.OutOfMemoryError: Direct buffer memory

David Holmes david.holmes at oracle.com
Tue Dec 29 20:36:18 UTC 2020


On 29/12/2020 7:15 pm, Florian Weimer wrote:
> * David Holmes:
> 
>> More accurately soft-references will be cleared before throwing an OOME
>> due to Java heap exhaustion. There are other things that can throw OOME
>> (like your array example, or "throw new OutOfMemoryError();") that don't
>> correspond to heap exhaustion and and so soft-reference clearing doesn't
>> enter the picture.
> 
> I think it's still a bug in the spec due to the way it is worded.

Yes:

"All soft references to softly-reachable objects are guaranteed to have 
been cleared before the virtual machine throws an OutOfMemoryError."

s/virtual machine/garbage collector/

Cheers,
David



More information about the core-libs-dev mailing list