myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Heinen" <>
Subject RE: statesaving - memory consumption
Date Tue, 02 Sep 2008 12:44:34 GMT
I extended the JspStateManagerImpl also for this reason (and for some
simple multi window support).

I removed the Map with the old views stored as weak references because
they are not useful at all in my App.
Benefit is that GC is more performant and that possible errors (View
could not be restored) are exactly reproducible and do not depend on
memory consumption.


-----Original Message-----
From: Daniel Niklas [] 
Sent: Dienstag, 2. September 2008 14:33
Subject: Re: statesaving - memory consumption

Hi Simon,

Simon Kitching wrote:
> The idea is that by setting NUMBER_OF_VIEWS_IN_SESSION, a webapp can 
> guarantee to support a certain number of back-button clicks - at the
> level at least.
> Or that when two windows are open on the same webapp, that the user
> perform NUMBER_OF_VIEWS_IN_SESSION clicks in one window before the
> window starts to misbehave.

Ok, our application doesn't need something like that, because we have
session beans...

Simon Kitching wrote:
> The "weak" map stuff then tries to make life nice for the user; when 
> there is memory to spare then it tries to keep as many old views as 
> possible, so that even more than NUMBER_OF_VIEWS_IN_SESSION clicks
> work. But when memory is low, only NUMBER_OF_VIEWS_IN_SESSION clicks
> guaranteed to work.
It might be a problem, that many of these objects are created and
the memory increases very fast. That means much effort for garbage
And most people (?!) doesn't need this mechanism at all.

Simon Kitching wrote:
> The original code used the default constructor for ReferenceMap, which

> uses strong refs to keys but weak refs to values. The key object here
> not large; it is the value (which is the whole UIViewRoot) that is
> weakly. However nothing *ever* clears the keys for this map. 

Yes, 1.1.5 uses the default constructor for ReferenceMap. But this
was not the problem! Entries of ReferenceMap will be removed when the
garbage collection runs (and there is no other hard reference to
the value), even if the corresponding key is hardly referenced!
No memory leak here. 

Simon Kitching wrote:
> I agree with your second posting, a weak references isn't a good
> choice here, soft references would be better, but no idea
> what was going wrong with 1.1.5. I'll check this.

Thanks for your answers
View this message in context:
Sent from the MyFaces - Users mailing list archive at

View raw message