M
Mark McKay
I have a large number of objects I load from disk and cache in a
HashMap. I'd like to know if the JVM is about to run out of memory,
and if so to then clear the eldest entries out of this cache. That
is, I'd like to be notified that an OutOfMemory error is about to be
thrown, and add some custom handling to try and free up space to
prevent it.
I've tried doing this with SoftReferences, but they're being cleared
long before I run out of memory.
Is there any way to implement a memory sensitive cache?
Mark McKay
HashMap. I'd like to know if the JVM is about to run out of memory,
and if so to then clear the eldest entries out of this cache. That
is, I'd like to be notified that an OutOfMemory error is about to be
thrown, and add some custom handling to try and free up space to
prevent it.
I've tried doing this with SoftReferences, but they're being cleared
long before I run out of memory.
Is there any way to implement a memory sensitive cache?
Mark McKay