[ 
https://issues.apache.org/jira/browse/WICKET-1959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12658409#action_12658409
 ] 

Johan Compagner commented on WICKET-1959:
-----------------------------------------

i am looking into this problem but the fix is not that straightforward.

I can make it a WeakHashmap, but that one i must make synchronized what i 
rather dont want to do (it is hit many many times in 1 request over multiply 
requests)
So i could make it a ConcurrentHashMap with a WeakClassReference key, the code 
will be uglier then because every time i access the map with a class i have to 
wrap the class in that key.
But that even wouldnt help us at all because what the WeakClassKey then points 
to will be an hard reference to a ConcurrentMap with String->IGetAndSet
And implementations of IGetAndSet can hold references to that class (if it is 
an Array lookup) or Methods/Field variables of that class
So i have a hard reference to that same class so it will never be out of scope

To fix that so having weak references everywhere will make the code overly 
complex because then suddenly fields or methods can be null even when i have a 
IGetAndSet object...
so i have to take that into account all over the place thats horrible.

So the question do you really make constant proxy classes? How come? Why does a 
session needs a new class?

But I think for us the only real fix will be to have a static setter on 
PropertyResolver:

PropertyResolver.setClassCacheCreator(Application application, 
IClassCachCreator creator)


IClassCachCreator 
{
  public Map createCacheMap(Class clz);
}

then it is up to you to return a map with an evict policy or for a specific 
class dont return anything then it will not be cached at all.


> PropertyResolver causes memory leaks with proxies
> -------------------------------------------------
>
>                 Key: WICKET-1959
>                 URL: https://issues.apache.org/jira/browse/WICKET-1959
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.5
>         Environment: All Platforms
>            Reporter: Gilad Garon
>            Assignee: Johan Compagner
>
> When using proxies for properties, a memory leak occurs.
> The ConcurrentHashMap classesToGetAndSetters  doesn't have an eviction policy 
> and fills up with proxies who do not get 
> garbage collected.
> Build a page which uses proxies as properties, every time a new session is 
> initiated, a new proxy (a new proxy is a new class) of the same property is 
> created and added to the map.
> if the proxy is create by a remote jvm you also get a classloader leak.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to