I am working on some JSP/Servlets application. It has a Shooping cart kind of thing, which I am keeping in my session. Every item added in the cart has different information and thus I need to get the current size of the Session before every new adition. I don't want it to become too heavy. I want the user to check out the items, if the session size exceeds a particular size. Though I can do this by keeping track of number of objects of different types in the session, but I don't want to do it that way. could any one suggest any other way of doing this.
Dhananjay Inamdar
Ranch Hand
Joined: Jan 27, 2003
Posts: 128
posted
0
Hello I don't think that there is direct method to check the SIZE of the SESSION object. There is one method of the SESSION object is "getAllAttributes", which returns the enumeration containing all the attributes stored in session. After receiving this enumeration you can check the size of this enumeration, which in turn will be the size of SESSION. I hope this will solve your problem -Dhananjay
Just like you, struggeling to get the right solutions!<br /> <br />Sun Certified Java Programmer 1.5<br /> <br />Target - SCWCD
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 11862
posted
0
The size of the enumeration will give the number of references, not the total memory used. There is no direct way in Java to get the exact memory used for something like a session. You can get a rough idea by serializing it out to a file and looking at the size of the file. Bill
Originally posted by William Brogden: ... There is no direct way in Java to get the exact memory used for something like a session. You can get a rough idea by serializing it out to a file and looking at the size of the file. Bill
That only works if 1) your session objects all implement Serializable and 2) The size of the .ser file is probably actually larger than the actual memory used by the session, because serialization includes class names and static class information. Actually, I think the remote debugging API *does* provide a way to measure memory usage. It's possible to use this with IBM WebSphere, which has a Performance Monitor tool. I am not really sure about exactly how it works though. Maybe someone can clarify.
Sudd Ghosh
Ranch Hand
Joined: Oct 23, 2002
Posts: 187
posted
0
Hi Michael - What is this "remote debugging API" ? Is this in the Java API specs or is it WebSphere specific ? Thanks, Sudd
Sun Certified Java2 Programmer-1.4<br />Sun Certified Web Component Developer for J2EE Platform<br />Sun Certified Business Component Developer for J2EE1.3
Vibhor Mittal
Greenhorn
Joined: Feb 04, 2003
Posts: 2
posted
0
Originally posted by Michael Zalewski:
Actually, I think the remote debugging API *does* provide a way to measure memory usage. It's possible to use this with IBM WebSphere, which has a Performance Monitor tool. I am not really sure about exactly how it works though. Maybe someone can clarify.
Do u know something of the same flavour in Weblogic. :roll: :roll: :roll: