Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BeanELResolver cache causes Class Loader leaks in app servers #214

Open
lprimak opened this issue May 2, 2024 · 4 comments · May be fixed by #215
Open

BeanELResolver cache causes Class Loader leaks in app servers #214

lprimak opened this issue May 2, 2024 · 4 comments · May be fixed by #215

Comments

@lprimak
Copy link

lprimak commented May 2, 2024

Currently, BeanELResolver caches Class elements in its SoftReference maps.
This causes it's ClassLoader to be referenced in the cache.
BeanELResolver internal SoftReference map only gets cleaned up via cleanup() method,
which doesn't necessarily get called often enough to prevent Out-Of-Memory errors.
The other issue is that, even when cleanup() is called enough to prevent OOMs,
the 'danglng' ClassLoaders cause VM to run at it's max memory capacity,
causing unnecessary GC and memory allocation thrashing.

clearProperties() method is needed to clear the cache from the ClassLoaders and thus prevent the leak

@lprimak
Copy link
Author

lprimak commented Jun 6, 2024

There is no way that I can think of to provide "automatic" scoping / cache invalidation.
Either SoftReference will use maximum amount of VM memory causing memory and GC thrashing,
or WeakReference will clear the cache with every GC.

My conclusion is to keep SoftReference and add clearProperties() method as in #215

@lprimak
Copy link
Author

lprimak commented Jun 9, 2024

@arjantijms My assumption is that this is an issue in GlassFish as well?
@starksm64 @bstansberry I see that IBM / RH use a fork of EL because of this issue?

I am sure that you guys would like to see a fix so you can start using "stock" version of EL at some point instead of needing to fork?

Thank you

@bstansberry
Copy link

@lprimak WildFly and JBoss EAP have long used our own variant of the EL API. We could likely stop doing that if our bean properties and factory finder caching use cases discussed in #218 were both handled in this project.

That said, it sounds like the need for the bean properties pieces is because Faces is holding a static ref to a BeanELResolver.

The WildFly project and the downstream Red Hat JBoss EAP product are produced independently of other EE implementations from IBM. So my comment here should not be interpreted as saying anything about IBM or any of its EE impls like Websphere, Liberty etc.

@lprimak
Copy link
Author

lprimak commented Jun 10, 2024

Thanks, Brian,

It sounds like BeanPropertiesCache is a non-starter because of java.beans dependency. However, once clearProperties() is added (#215 is merged) that should solve the BeanPropertiesCache case.

Also sounds like FactoryFinderCache can be merged into EL as is.

Am I understanding things correctly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants