Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
Models Implementation 1.6.4
-
None
-
None
Description
There have been several instances of issues with model caching over the years, the most recent being SLING-12259 and this thread from Jörg Hoh. These recent issues have been around cached items sticking around for too long. In that thread, it was discussed using ResourceResolver#getPropertyMap() whenever possible. This binds the cache to the lifecycle of the ResourceResolver, avoiding the global cache altogether.
After looking at the current implementation, there is already a divergence that binds the cache for request-based models to the request, by putting the cache in the request attribute.
This proposes to do a similar change for Resource/Resolver based models, and use the resolver's property map to bind the cache for those adaptables to the lifecycle of the ResourceResolver. Resources are already (largely) bound to the lifecycle of the ResourceResolver that supplied them, and binding the models that come from these Resources seems to be a reasonable approach.
This will greatly reduce the lifetime of model objects, reducing the likelihood of the JVM's GC being put under pressure in cases when cached models reference the original adaptable using @Self. As a bonus, if the cache object implements Closeable, the Sling Implementation will call close() on the cache when the resolver is closed,, giving us further control over the lifetime of objects in the cache.
Attachments
Attachments
Issue Links
- relates to
-
SLING-12259 ModelFactory adatpercache does not cleanup entries
- Open
- links to