Wednesday, December 19, 2007

Java Sizeof() & sessions

I've just been doing some stuff to optimise our infrastructure to stop it calling an external ejb 6 times per request, which I fixed by sticking stuff in the session. there's similar problems in other places in our app and I was thinking about sticking them in the session as well, but then the issues of session size/scalability & stale data stopped me.
long story short, I found some interesting stuff on reinventing the sizeof operator for java. in C you use it all the time, but in java such a thing doesn't exist. Now, you could go and profile your application, but that usually takes a bit of setting up, and if you want to instrument your app in production then it doesn't really work so good.
Anyhoo, here's three interesting links on the topic of figuring out how big objects in java are in general, and session size in particular:
[1] how big are primitives? brute force approach, useful for boot-strapping
[2] Article developing the issue and source of tool to get a good (approximate) idea of the size of an arbitrary rooted graph.
[3] Java web parts helper class to determine size of your session

No comments: