• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Management--Telling objects to go away!

 
Russell Ray
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would someone be so kind to point in the right direction on how to manage a web session? I have a web application and the memory footprint continues to grow as users kill their browsers. I have been told WAS is hanging onto objects to long. The best way to handle this quickly is manage the session programmatically and destroy the objects when the session is "terminated" by killing the browser.

Thank you for taking the time to read my post!

Russ
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the session expires, the objects will be released and free for Garbage Collection (GC).

There is no reliable way to know when a browser has been closed.
You might want to shorten the length of your sessions.

I have been told WAS is hanging onto objects to long.

You've been told by whom?
And, what is "too" long?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also note that you can remove individual references when they are no longer needed with the HttpSession method "removeAttribute" - depending on your architecture you may be able to reduce the memory footprint that way.
Bill
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The best way to handle this quickly is manage the session programmatically and destroy the objects when the session is "terminated" by killing the browser.

True. Assuming you can accurately communicate to the server when a browser window is closed, which unfortunately you can't, and assuming the user will actually close the browser when they are finished, which they may not. The usual way to handle this is to time inactive sessions out. Search this forum if you don't know how to do that.

(Dang! Too slow)
[ June 17, 2005: Message edited by: Paul Sturrock ]
 
DC Dalton
Ranch Hand
Posts: 287
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh yes the old "stupid users wont use the logout function on my site" problem... man I know it all too well. I would have to ask a few questions..

what kind of goodies are you storing in the users sessions? (hopefully not the magna carta)

are you setting the interval for time out with setMaxInactiveInterval? (if so for how long)

there is a semi decent way to remind them or force them to log out.. I actually just found it a while back but its not 100% (may help though) in Javascript there is a function called onbeforeunload... you place it in your body tag just like the onload .... now here's where it gets kind of tricky. You have to check to make sure they are closing the page or going to a site OTHER than your and if they are you can throw a confirm at them. If they click the OK on the confirm you can use a location.href to send them thru a logout servlet.. if not you set the onbeforeunload to null and they get no confirm. It a pai but I have used it in an online appplication and it worked pretty good.

the part that sucks about it is if they have javascript disabled, then it wont work.

You may want to look into that and HOW MUCH info you are storing in the sessions. If you are sucking up tons of memory I have a feeling you may be stuffing too much into them..

Hope this helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic