Hi,

I just committed a new toy for Wicket. wicket.util.Objects now uses a
simple strategy class to delegate calculating object sizes for method
sizeOf (which is used in various places in Wicket, e.g. in the
inspector bug). As an alternative implementation, I added project
wicket-objectsizeof-agent, which only lives in the 1.3 branch, but
should work just as well for 2.0. To use this, make a jar using mvn
clean install (or get a snapshot from bamboo when it's available) and
start up your application providing a -javaagent argument that points
to the resulting jar. For instance, I used for my computer:
-javaagent:/Users/eelcohillenius/.m2/repository/org/apache/wicket/wicket-objectsizeof-agent/1.3-incubating-SNAPSHOT/wicket-objectsizeof-agent-1.3-incubating-SNAPSHOT.jar

The instrumentation class will take care for pluggin in the strategy,
so besides providing that parameter there is nothing you need to do.

The calculation is based on counting the objects that would be
serialized when using Java's default serialization. This is similar to
what we did before, but now it counts using the instrumentation class
rather than the bytes. This should eliminate bytes for class headers
etc (which aren't very useful in the calculation) but otoh adds some
of the overhead of the JVM you wouldn't have when serializing. I don't
know, it still seems pretty tricky to get good memory measurements of
isolated objects.

I hope more people ditch in here and think with us/ tweak/ test to get
this as accurate as we can. So... please play with it and give
feedback here.

Oh, it's JDK 5+ only, and if you are using JDK 6+ you can even attach
the agent dynamically to a running JVM (though at this time there is
no facility for detaching... patches are welcome).

Cheers,

Eelco

Reply via email to