On 31 Jan 2012, at 09:34, Bela Ban wrote:
IMO, measuring object size using java.lang.instrument is not a good
idea: first of all, it's probably very slow and the time to do so is
linear to the number of live objects.
+1
I remember prototyping this for JBossCache and the harness and that's what I found as
well.
Second, this probably takes into
acount only objects in the cache, but not the cache structures used by
Infinispan, JGroups and so on...
The approach I've recommended before is to trigger an eviction policy
based on free/available memory. This can easily be fetched from the JVM
via JMX...
..or keep the in-memory data in serialized form (byte[]) - that can be
counted - and add an empiric factor (TBD) for the harness/ISPN structure that holds the
data. AFAIK coherence does this.