Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SessionBean vs. RequestBean  RSS feed

 
Anthony Sykes
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a fan of preserving memory. With that said, could someone answer a few questions for me? 1) What happens to SessionBeans when they are not being used? Are they Serialized or do they just hang out in memory? What happens when someone's session expires? What happens behind the scenes (on the container) in the SessionBean scenario as far as memory management is concerned?
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anthony Sykes:
I am a fan of preserving memory. With that said, could someone answer a few questions for me? 1) What happens to SessionBeans when they are not being used? Are they Serialized or do they just hang out in memory? What happens when someone's session expires? What happens behind the scenes (on the container) in the SessionBean scenario as far as memory management is concerned?

All *stateful* session beans will be passivated once the contained decides that they are not in use. So, those instances will not hog memory.
 
Anthony Sykes
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the determination made in considering when to write the object out of memory? Also what happens to the instance variables contained within the bean? Are they reclaimed by the garbage collector or do they persist as well? Say, for example, you have a portal application that can have several hundred thousand users logged in at any given time. Could this be a problem for session beans. Also, what does this mean for the hard drive? I would imagine alot of usage here.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the determination made in considering when to write the object out of memory?

This is determined by the app server, based on which server you are using, there are different parameters that you can set to control this behavior. For instance, if you use weblogic, then this article may help.
Also what happens to the instance variables contained within the bean? Are they reclaimed by the garbage collector or do they persist as well?

Passivation, follows the serialization principals, so all non-static non-transient fields will be passivated. (Googling will give you enough insight into this.)
Say, for example, you have a portal application that can have several hundred thousand users logged in at any given time. Could this be a problem for session beans.
Also, what does this mean for the hard drive? I would imagine alot of usage here.

Yeah, the disk usage will be huge, if you want your session beans to last for a very long time. Ideally, one must do analysis of whether the bean really is required to be stateful. A session bean is supposed to hold a user's conversational state. All permanent data must be stored in a DB probably using an entity bean. Using a stateful session bean to hold permanently stored data may be a bad choice, one should think of using an entity bean in this case.
Also, if a state is to be retained, then it will either be in-memory or in disk. If you want less disk usage then you keep in memory, if less memory foot print then put it on disk. But, in either case, one of the resource will be used when the data to be retained is huge.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, this topic does not belong to the JSF forum. Its strange that this one slipped from the eagle-eyes of the moderators
[ September 17, 2007: Message edited by: Nitesh Kant ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!