----- Original Message -----
From: "Rohan Shrinivas Desai" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, December 29, 2001 12:59 AM
Subject: Session Variables


> Hi All,
>
>         Happy New Year to all of you.. !
>         i nees some basic info about sessions.
>         how advisable is it to use sessions generously in the application
> running on servlets. ?
>         is it advisable to store objects such as Vectorsor ResultSets in
> session.
>         how does the session stores these objects ?
>         is it that it stores only the reference of these objects, or it
> stores the object physically ?
>         what i want to know basically is ....
>         does the size of the Vector or ResultSet matters when we store
them
> in session ??
>
> Thanx..
> Regards,
> Rohan
>[...]


I think some Servlet-containers will use java.util.Hashtable to hold (the
reference) of the "Attibute" of a HttpSession.  now when you invoke
setAttibute/getAttibute of HttpSession, put/get of Hashtable will be
invoked.

java.util.Hashtable use a Entry[] to do it, and when you invoke its
put(Object key, Object value) method, "value" will Not be
"shallow/deep cloned", so only the reference of "value" is stored.
and when you invoke its get(Object key) method later, you will get
that reference, and you can use this reference to access the original
"value".

although there will not be a "clone of value" which needs more memory
to be allocated,  but you still need to consider the size of "value" for
saving
the momory.  And because now there are more references of  "value",
and  "value" will not be GCed before all such references are set to null,
so when you don't need the "value", perhaps it is better for you to "remove"
that its reference before the HttpSession is "invalidated".


Bo
Dec.29, 2001

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to