thanks a lot simon, In fact i got a memory leakage in the application. there will be a list of components stored in cache using the saveState. Do u think the app server *may* miss-handle those "should be GC" component trees?
Simon Kitching-3 wrote: > > Dellee wrote: >> Hi all, >> I am new to myFaces and I think a little bit confusing on the >> saveState >> option. >> When using the saveState, will it keep referencing the beans that it >> pointed >> to ? >> if yes, will this cause a memory leak coz the pointed bean should be died >> and GC after the server method finished. >> However, as someone is pointing to it (by saveState), so it still alive >> and >> won't be collected when GC start. >> what do u think ? >> am i mis-understanding something ? > > The t:saveState tag simply "attaches" the object referenced by its value > expression to the JSF component tree. That data therefore has exactly > the same lifetime as the JSF component tree, and will be discarded when > the tree is discarded. > > One of the major points of JSF is that when a request completes, the JSF > component tree is either stored server-side or encoded in the html page, > and then restored to its former state after the user clicks a > commandButton or commandLink. > > When the same page is being redisplayed repeatedly, the component tree > continues to exist [1]. > > When navigation to a different page occurs, the current JSF component > tree is discarded, and a new one created for whatever new page is being > displayed. [2] > > Using t:saveState ensures that the referenced object is kept around for > exactly the same time as the component tree. > > [1] In most cases, it's not exactly the same component instances; the > data is serialized at the end of the render phase, then in "restore > view" an "identical" component tree is recreated with the same contents. > This is why the target of a t:saveState tag needs to either implement > java.io.Serializable or javax.faces.component.StateHolder. > > [2] Well, a configurable number of "old" component trees are cached in > memory to support multiple concurrent windows, and back-button usage. > This defaults to 20. Component trees only get garbage-collected once > they are pushed out of this cache by newer component trees. > > Regards, > > Simon > > -- View this message in context: http://www.nabble.com/Will-saveState-cause-memory-leak--tf3190843.html#a8858572 Sent from the MyFaces - Users mailing list archive at Nabble.com.