Is it possible to determin what the size of a session is? I have a class that implements HttpSessionBindingListener, when the valueBound method is invoked, I want to determine what the size of the session is. Thanks in advance.
The easiest way to do that is to serialize the HttpSession object onto a ByteStream and then look at the size (byte position) of the resulting ByteStream. I used to have some code that did that somewhere -- I'll post it if I can find it...
You can't get an estimate of the "size" of a session - if you mean the amount of memory the session occupies. A session can have references to all sorts of objects. Since the HttpSession object itself is just a collection plus some bookkeeping, an instance is pretty small.
The amount of memory that would be released when the session is invalidated depends on whether or not those objects can be GCed. A session that is holding on to references to lots of big objects - where those references are the only thing that prevents GC - might be considered "big". Bill