You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Dellee <de...@yahoo.com.hk> on 2007/02/07 11:09:56 UTC

saveState will cause memory leak?

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 ?

Thanks for any help!

Dell
-- 
View this message in context: http://www.nabble.com/saveState-will-cause-memory-leak--tf3185987.html#a8842756
Sent from the My Faces - Dev mailing list archive at Nabble.com.


Re: saveState will cause memory leak?

Posted by Dennis Byrne <de...@dbyrne.net>.
Dellee ,

Please ask these questions on the users@myfaces.apache.org mailing list.

Thanks,

Dennis Byrne

On 2/7/07, Dellee <de...@yahoo.com.hk> 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 ?
>
> Thanks for any help!
>
> Dell
> --
> View this message in context:
> http://www.nabble.com/saveState-will-cause-memory-leak--tf3185987.html#a8842756
> Sent from the My Faces - Dev mailing list archive at Nabble.com.
>
>


-- 
Dennis Byrne

Re: saveState will cause memory leak?

Posted by Werner Punz <we...@gmail.com>.
Dellee schrieb:
> thanks for ur reply. 
> 
> in fact i experience a memory leakage problem when i keep clicking and
> refreshing a list.
> stuff in the list will be stored in cache by the saveState option.
> 
> after i click to refresh that list for serveral times, the app hanged w/
> outofmemory exception. 
> I wonder if the cached list objects cannot be completely remove and GC in
> the next cycle. 
> any idea on what's happening?
> 

If you have server side state saving turned on,
you will have a history saved (most likely in your session) which is
rolled back in case
of a back button case, this is done due to the fact
that the back button needs to perform consistently on the client and server.


Following:
I do not think this is a memory leak, but you simply run into an out of
memory condition, due to the back button history saving the list
10-15 times depending on your settings

you can alter the state history settings by a simple parameter in the
config files(I do not know it yet, please others jump in here)

also check if the problem is gone via client side state saving
if yes, then it is probably the back button history in combination
with server side state saving.


You can avoid this situation by disabling the state history, or by
reducing it, or by increasing your servers ram.




Re: saveState will cause memory leak?

Posted by Dellee <de...@yahoo.com.hk>.
thanks for ur reply. 

in fact i experience a memory leakage problem when i keep clicking and
refreshing a list.
stuff in the list will be stored in cache by the saveState option.

after i click to refresh that list for serveral times, the app hanged w/
outofmemory exception. 
I wonder if the cached list objects cannot be completely remove and GC in
the next cycle. 
any idea on what's happening?



Werner Punz-2 wrote:
> 
> Dellee schrieb:
>> 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 ?
>> 
> First of all I am moving this into the users list.
> The devs list is for development discussions on myfaces.
> 
> Yes you misunderstand something:
> saveState uses the jsf internal save restore mechanisms, hence
> every object which is referenced by safestate is serialized and
> deserialized at every request, so no memory leak situation theoretically
> can occur
> unless the serialisation happens into the session
> (this is app server dependent)
> 
> besides that once you reach a page where savestate  is not referenced
> anymore the object is basically dropped from the save restore cycled
> and fed into the garbage collector at the next save cycle.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-saveState-will-cause-memory-leak--tf3186226.html#a8858615
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: saveState will cause memory leak?

Posted by Werner Punz <we...@gmail.com>.
Dellee schrieb:
> 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 ?
> 
First of all I am moving this into the users list.
The devs list is for development discussions on myfaces.

Yes you misunderstand something:
saveState uses the jsf internal save restore mechanisms, hence
every object which is referenced by safestate is serialized and
deserialized at every request, so no memory leak situation theoretically
can occur
unless the serialisation happens into the session
(this is app server dependent)

besides that once you reach a page where savestate  is not referenced
anymore the object is basically dropped from the save restore cycled
and fed into the garbage collector at the next save cycle.