Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Measuring the Size of HttpSession object

Is there a clean and easy way to measure it other than programatically measuring the size of each data type (that each object is composed of) stored in session?

like image 817
Langali Avatar asked Oct 27 '09 21:10

Langali


People also ask

How do I find HttpSession?

How to get the HttpSession object ? The HttpServletRequest interface provides two methods to get the object of HttpSession: public HttpSession getSession():Returns the current session associated with this request, or if the request does not have a session, creates one.


1 Answers

MessAdmin allows you to compute the HttpSession size although it is unclear on how it calculates the size of transient objects.

It appears that getting an approximate size of the HttpSession object is an exercise in futility in production, and one is likely to get a more accurate size for a controlled environment.

One thing to note is that size of the serialized session object is bound to inaccurate due to changes in character encoding - Strings in Java are stored in the UTF-16 format whereas the output stream could be in a different encoding. More details on why calculating the size of an object in Java is a problem, can be found in this JavaWorld article.

like image 141
Vineet Reynolds Avatar answered Sep 19 '22 13:09

Vineet Reynolds