Skip to content

Instantly share code, notes, and snippets.

@gennad
Created February 2, 2011 08:32
Show Gist options
  • Save gennad/807407 to your computer and use it in GitHub Desktop.
Save gennad/807407 to your computer and use it in GitHub Desktop.
Object size fetcher
import java.lang.instrument.Instrumentation;
public class ObjectSizeFetcher {
private static Instrumentation instrumentation;
public static void premain(String args, Instrumentation inst) {
instrumentation = inst;
}
public static long getObjectSize(Object o) {
return instrumentation.getObjectSize(o);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment