Sumanta Pakira created SLING-12259:
--------------------------------------
Summary: ModelFactory adatpercache does not cleanup keys when
weakreference are collectd
Key: SLING-12259
URL: https://issues.apache.org/jira/browse/SLING-12259
Project: Sling
Issue Type: Bug
Reporter: Sumanta Pakira
When the model cache is enabled, then the adapter cache map keeps on growing
which caused memory leaks.
For example, In an application when adapting to a resource of type dam:Asset
then in this [line of
code|https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java#L351]
the Map keeps on growing. Because WeakHashMap value gets Garbage collected
faster, so the values are removed but the keys remain.
One way to solve this would be, some housekeeping to remove key-value pairs
that have had their {{SoftReferences}} cleared.
The approach I think could be one map that maps between the cache key and weak
referenced values and one in the opposite direction mapping between the weak
referenced values and the keys and reference queue and a cleanup thread.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)