You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Howard Lewis Ship <hl...@gmail.com> on 2011/10/13 20:40:50 UTC

SoftReference vs. WeakReference for page instances

I've always thought that Tapestry would scale nicely to very, very
large applications. Now I'm a bit concerned having seen a very large
application in Tapestry.  Nearly 700 pages many of which have more
than 5000 components.  This dwarfs the other big Tapestry applications
I've seen.  Even with live class reloading, these people are seeing 20
- 30 seconds or more to reload a page after a change.

One thing I'm considering is changing the cache inside the PageSource
service to use WeakReferences, rather than SoftReferences, for pages.
I may make that optional, perhaps with a symbol
"tapestry.large-application-optimizations" that could be enabled to
choose which mode to run things in.  Most of this will need to slip
into Tapestry 5.4.

What I'm seeing is that after (attempting to) load all pages, the app
is quite memory starved (over 1 gb of memory usage) but the JVM
doesn't seem to be evicting my soft references.  I'm looking for
places those references can leak. but not finding any.

-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Re: SoftReference vs. WeakReference for page instances

Posted by Howard Lewis Ship <hl...@gmail.com>.
I need to go back in with a profiler to see what's going on.
Basically, we're hitting the needle against max vm heap size (1 gb)
but even after many minutes, the page instances are not being
discarded.

On Thu, Oct 13, 2011 at 12:14 PM, Martin Strand
<do...@gmail.com> wrote:
> On Thu, 13 Oct 2011 20:40:50 +0200, Howard Lewis Ship <hl...@gmail.com>
> wrote:
>
>> One thing I'm considering is changing the cache inside the PageSource
>> service to use WeakReferences, rather than SoftReferences, for pages.
>> I may make that optional, perhaps with a symbol
>> "tapestry.large-application-optimizations" that could be enabled to
>> choose which mode to run things in.  Most of this will need to slip
>> into Tapestry 5.4.
>>
>> What I'm seeing is that after (attempting to) load all pages, the app
>> is quite memory starved (over 1 gb of memory usage) but the JVM
>> doesn't seem to be evicting my soft references.  I'm looking for
>> places those references can leak. but not finding any.
>
>
> That might not be a leak, unused SoftReferences are by default kept alive
> for 1 second per available MB of heap space:
> http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#gc_softrefs
> If you set -XX:SoftRefLRUPolicyMSPerMB to a low value they should be evicted
> much faster.
>
>
> also, the server VM will attempt to expand the heap in order to avoid
> clearing SoftReferences:
> http://stackoverflow.com/questions/299659/what-is-the-difference-between-a-soft-reference-and-a-weak-reference-in-java/299702#299702
>
>> the policy for the "-client" and "-server" JRE's are different:
>> the -client JRE tries to keep your footprint small by preferring
>> to clear SoftReferences rather than expand the heap, whereas
>> the -server JRE tries to keep your performance high by preferring
>> to expand the heap (if possible) rather than clear SoftReferences.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: dev-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Re: SoftReference vs. WeakReference for page instances

Posted by Martin Strand <do...@gmail.com>.
On Thu, 13 Oct 2011 20:40:50 +0200, Howard Lewis Ship <hl...@gmail.com>  
wrote:

> One thing I'm considering is changing the cache inside the PageSource
> service to use WeakReferences, rather than SoftReferences, for pages.
> I may make that optional, perhaps with a symbol
> "tapestry.large-application-optimizations" that could be enabled to
> choose which mode to run things in.  Most of this will need to slip
> into Tapestry 5.4.
>
> What I'm seeing is that after (attempting to) load all pages, the app
> is quite memory starved (over 1 gb of memory usage) but the JVM
> doesn't seem to be evicting my soft references.  I'm looking for
> places those references can leak. but not finding any.


That might not be a leak, unused SoftReferences are by default kept alive  
for 1 second per available MB of heap space:
http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#gc_softrefs
If you set -XX:SoftRefLRUPolicyMSPerMB to a low value they should be  
evicted much faster.


also, the server VM will attempt to expand the heap in order to avoid  
clearing SoftReferences:
http://stackoverflow.com/questions/299659/what-is-the-difference-between-a-soft-reference-and-a-weak-reference-in-java/299702#299702

> the policy for the "-client" and "-server" JRE's are different:
> the -client JRE tries to keep your footprint small by preferring
> to clear SoftReferences rather than expand the heap, whereas
> the -server JRE tries to keep your performance high by preferring
> to expand the heap (if possible) rather than clear SoftReferences.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org