How can we find out the size of a java object??
Example:
class Person{ String name; int age; public Person(String n, int a){
EhCache provides a SizeOf class that will try to use the Instrumentation agent and will fall back to a different approach if the agent is not loaded or cannot be loaded (details here).
Also see the agent from Heinz Kabutz.