You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by richard emberson <ri...@gmail.com> on 2010/10/05 23:20:21 UTC

DefaultPageStore.scala SoftReference cache

In the SerializedPagesCache class' storePage method one
might consider changing:


to:

     if (cache.size() == size)
     {
         cache.remove(0);
     }
     cache.add(ref);

Avoids allocating a bunch of unused slots in the ArrayList.

Also, the garbage collector reaps (clears) soft references over time,
which is to say, refs in the cache may have their page's set to null.
Adding active pages at the back of the cache and removing from the
front works, but some slots with pages may be removed from the
front while other refs with their pages cleared by the GC may
still be in the cache. Since the storePage method sweeps through
all elements of the cache one might consider adding:
     if (ref == null {
         i.remove()
     } else {
         SerializedPage entry = ref.get()
         ....
     }
Again, not real important unless one's web server might occasionally
operate near its max-memory.

Richard
-- 
Quis custodiet ipsos custodes