public interface CacheOptions<T> extends Options<T>
Modifier and Type | Interface and Description |
---|---|
static class |
CacheOptions.CacheType
Rough in-memory cache types.
|
static interface |
CacheOptions.Val |
Modifier and Type | Method and Description |
---|---|
default T |
cacheType(CacheOptions.CacheType cacheType)
Which in-memory cache type to use.
|
default T |
maxCacheSize(long maxCacheSize)
Set the maximum number of values (cells) to keep in the cache.
|
default T cacheType(CacheOptions.CacheType cacheType)
SOFTREF
: The cache keeps SoftReferences to
values (cells), basically relying on GC for removal. The advantage of
this is that many caches can be created without needing to put a limit on
the size of any of them. GC will take care of balancing that. The
downside is that OutOfMemoryError
may occur because
SoftReference
s are cleared too slow. SoftReferences are not
collected for a certain time after they have been used. If there is heavy
thrashing with cells being constantly swapped in and out from disk then
OutOfMemory may happen because of this. This sounds worse than it is in
practice and should only happen in pathological situations. Tuning the
-XX:SoftRefLRUPolicyMSPerMB
JVM flag does often help.BOUNDED
: The cache keeps strong references
to a limited number of values (cells). The advantage is that there is
never OutOfMemory because of the issues described above (fingers
crossed). The downside is that the number of cells that should be cached
needs to be specified beforehand. So OutOfMemoryError
may occur
if many caches are opened and consume too much memory in total.cacheType
- which cache type to use (default is SOFTREF
).default T maxCacheSize(long maxCacheSize)
cacheType(CacheType)
is CacheOptions.CacheType.BOUNDED
.maxCacheSize
- maximum number of values in the cache (default is 1000).Copyright © 2015–2022 ImgLib2. All rights reserved.