How can we find out the size of a java object??
Example:
class Person{
String name;
int age;
public Person(String n, int a){
I think you can get something that might help you if you do something like this:
/* First trigger classloading */
MyObject delegate = new MyObject();
Runtime.getRuntime().gc();
long before = Runtime.getRuntime().freeMemory();
MyObject delegate2 = new MyObject();
long after = Runtime.getRuntime().freeMemory();
System.out.println("Memory used:"+(before-after));
This will hopefully give you the answer you want, or at least an approximation.