File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes HttpSession ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpSession ..." Watch "HttpSession ..." New topic
Author

HttpSession ...

Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
hi all,
Could anyone clear my doubts regarding HttpSession..
1) Is storing the objects in session a good process with respect to memory management.i mean, does session objects take too much memeory ??
2) pardon me if this is a dumb question
i have String Str1 which has about 3000 charactes..
and another String Str2 which has only 3 characters
im putting Str1 in one session and Str2 in another session..
Does Str1 and Str2 (size of the data it holds) play any role in memory consumed by the session ???
Thanks
Raj


SCJP, SCWCD, SCBCD, Oracle Certified Professional (SQL n PL/SQL)
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

1) It depends on what you put in the session. I have seen recommendations between 1K and 10K for optimal session size. You can write out a sample session to a file if you want to see how much memory it takes up (see ObjectOutputStream in the API.)
2) Yes, the bigger string will take up more memory. Everything you put in the session uses some memory. Even a field set to null will take up a byte.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
Thanks Jeanne
Raj
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: HttpSession ...
 
Similar Threads
String Problem
Strings Immutable ??
Object and String
Memory issue between implements and extends
Unable to undustand the System.out.println behaviour