1/16 Does anyone know how to query the maximum (or at least current) JVM
heap size at runtime? I'd like to be able to set the max JVM heap size
(-Xmx512M) in a script and have my app sense that and use the number
in sizing its caches. Is there any good way to do this?
\_ Runtime.{free,total,max}Memory() will give you the numbers you want.
If this is for caches, you might also want to look into the
SoftReference and WeakReference classes in java.lang.ref. -gm
\_ Yeah, I've thought of WeakReferences for the next refactoring,
but I'm worried about data I want to cache for a future similar
query getting GC'd out from under me. -OP
\_ Oh, yeah, thanks. -OP |