• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Serialised session size

 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
If I serialise a http session to obtain the size in bytes how accurate is it? Is the true size of the session in the app server likely to be much different to the size seen when serialised?
Cheers,
Steve
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The size of the serialized object should be indicative of the in-memory object, but note that if there are a lot of Strings in the session, the memory will be taking 2 bytes per character.
Bill
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the how to determine the size of your persistent http session. Place this code in the doGet/doPost:
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream stream = new ObjectOutputStream(out);
stream.writeObject(request.getSession());
stream.flush();
System.out.println("Total Size: " + out.size + "bytes");
Erick
 
Erick Jones
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I may have misunderstood the question. Are you trying to figure out the peristent size, or the in-memory size? They are not the same. The persistent size of an object is much larger than the memory it consumes.
My previous post assumes you are interested in the persistent size. If you want to know the in memory size it is not quite that simple, but here is an article that I found that will allow you to figure it out.
http://www.webgain.com/communities/developers/resources/articles/newsletter_1.html
Cheers
 
Steve Granton
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
We've been experiencing Out of Memory errors with Websphere 4.0 and I am trying to establish the size of the session at various points in the application - so I guess I'm interested in the in memory session size - I was hoping that the serialised session size will be indicative of the in memory size but it appears not. I'll take a look at the article you suggested.
Thanks for the help,
Steve
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know this is an old topic, but the link to the article cannot be found now. Does anyone have any information on how to calculate the in-memory session size?

Thanks.


Stuart
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This isn't that easy to do because several sessions could hold references to the same object.

One approach would be to use a profiler such as JProbe, or Optimizeit and measure the overall memory footprint as sessions are added.
 
It's a tiny ad. At least, that's what she said.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic