J
Jesper Nordenberg
I'm writing an application where I have a memory cache of objects
stored on disk. There are no limitations on the object sizes, one
object can be as large as the heap. A long value is used to identify
an object, so there can be a huge amount of objects.
I want to use a fixed amount of the heap or all the available heap for
the cache. I can't cache a fixed number of objects since I don't know
how how much memory an object occupies, and thus the program can run
out of memory. So, using SoftReferences seems like a good solution.
One problem is that the HashMap used in the cache can become very big
and needs to be cleared of SoftReferences that has been nullified.
If someone have some implementation or design suggestion that would be
great. Maybe there is some open source project that implement a
similar cache?
/Jesper Nordenberg
stored on disk. There are no limitations on the object sizes, one
object can be as large as the heap. A long value is used to identify
an object, so there can be a huge amount of objects.
I want to use a fixed amount of the heap or all the available heap for
the cache. I can't cache a fixed number of objects since I don't know
how how much memory an object occupies, and thus the program can run
out of memory. So, using SoftReferences seems like a good solution.
One problem is that the HashMap used in the cache can become very big
and needs to be cleared of SoftReferences that has been nullified.
If someone have some implementation or design suggestion that would be
great. Maybe there is some open source project that implement a
similar cache?
/Jesper Nordenberg