Saturday, December 27, 2008

Beta: Classmexer agent

The beta version of a simple instrumentation tool is available for download from the Javamex site. The Classmexer jar provides various calls for querying the memory usage of Java objects. Via the provided MemoryUtil class.deepMemoryUsageOf() method, it is possible to get an estimate from the JVM of the number of bytes taken up by an object and its "subobjects" (objects referred to by a non-public reference, or by references with other visibility criteria). The memory usage of subobjects is combined recursively (so subobjects of subobjects are considered etc), but without counting the same object more than once.

A variant of the call is also provided which gives the total memory usage of several objects at a time, without counting as duplicates objects referenced by more than one of the objects.


Anonymous said...

Man, this tool is really helpfull. The only shortcoming is the speed: calculating memory usage for ArrayList with relatively complex objects and size()~1000000 takes a long time. But seems this is unavoidable thing, because your util crawl into the tree of the objects with the specified object as root.

Anonymous said...

Hi there,
I use your classmexer agent to calculate memory of images I load.
I would like to make the tool I am writting publically available (open source).
In your copyright notice write:
"However, you may
NOT redistribute the Software to third parties without express permission."

I have found no other way to contact you - so I use your blog.

I would like to include your library with my program in order for the tool to be distributed as a "whole". I will give credit and add a pointer to your homepage.
Do I have your permission to do so?



Neil Coffey said...

Please contact if you are interested in purchasing a licence for commercial distribution.