It is possible to reference the same object through multiple session
attributes. I often do this to allow shorthand access to heavily nested
properties.

Your method would count multiple references to the same object multiple
times.

An alternative approach would be to look at the amount of memory used by
your application running with 200 users, then destroy 100 sessions and force
grabage collection (or wait for it to happen). The difference in memory
usage would tell you how much memory 100 sessions actually needed.

Paul

> -----Original Message-----
> From: Khalid K. [mailto:[EMAIL PROTECTED]
> Sent: 22 January 2004 04:01
> To: 'Struts Users Mailing List'
> Subject: HttpSession size - is this code correct?
> 
> 
> Hi,
> 
> I am trying to dertemine the size of the session object, 
> I've looked around and have written the following, please let 
> me if this
> is correct.
> 
>       Enumeration e = session.getAttributeNames();
>       ByteArrayOutputStream  bos = new ByteArrayOutputStream();
>       ObjectOutputStream s = new ObjectOutputStream(bos);
> 
>       while (e.hasMoreElements()) {
>               Object o = session.getAttribute((String)
> e.nextElement());             
>               s.writeObject(o);
>               s.flush();
>       }
>       System.err.println("size = " + bos.size());
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.564 / Virus Database: 356 - Release Date: 1/19/2004
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


**************************************
Axios Email Confidentiality Footer
Privileged/Confidential Information may be contained in this message. If you are not 
the addressee indicated in this message (or responsible for delivery of the message to 
such person), you may not copy or deliver this message to anyone. In such case, you 
should destroy this message, and notify us immediately. If you or your employer does 
not consent to Internet email messages of this kind, please advise us immediately. 
Opinions, conclusions and other information expressed in this message are not given or 
endorsed by my Company or employer unless otherwise indicated by an authorised 
representative independent of this message.
WARNING:
While Axios Systems Ltd takes steps to prevent computer viruses from being transmitted 
via electronic mail attachments we cannot guarantee that attachments do not contain 
computer virus code.  You are therefore strongly advised to undertake anti virus 
checks prior to accessing the attachment to this electronic mail.  Axios Systems Ltd 
grants no warranties regarding performance use or quality of any attachment and 
undertakes no liability for loss or damage howsoever caused.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to