sizeofag is a Java Agent that allows you to determine the size of Java objects from within the JVM at runtime. This makes it very useful for developing Java frameworks that take memory constraints into account. This project is based on Maxim Zakharenkov’s code and released under LGPL v3.

I modified Maxim’s original code and added Maven build support, put it on Github and published it on Maven Central as well.

See this wiki page for an example on how to use the agent.