Activating CDI creates classloader leak in tomee/tomcat

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Activating CDI creates classloader leak in tomee/tomcat

makkus
Hi folks,

by tracing down a classloader leak in my webapp I realized, that leaks are
actually created by activating CDI via adding the "beans.xml" into WEB-INF
(TomEE plume 8.0.0-M2 and TomEE plume 8.0.0).
To reproduce, I have created a minimalistic jsf enabled webapp consiting of
onyl a simple ServletContextListener (called leaktest.AppContextListener).
Feel free to download the test war archive here:
https://1drv.ms/u/s!AlHB9FAlFWW_iLJjPO5NAk77apcO4g?e=gjFDoY 

When reloading the application inside tomcat multiple times and stopping it,
for each load one leaktest.AppContextListener class reference can be found
in the heapdump classes
<http://tomee-openejb.979440.n4.nabble.com/file/t376354/leakWithBeans.jpg>
When renaming "beans.xml" into something invalid like "_beans.xml" the
classloader leak disappears, only a single leaktest.AppContextListener class
can be found in the heapdump after the app is stopped. Tomcats leak
detection button confirms this observation. Without CDI enabled (i.e.
invalid "_beans.xml") the leak message inside the manager app lists only a
single line (even with repreated reloads). With CDI enabled (valid
beans.xml) for each reload an new line is added in the leak message window
of the tomcat web application manager.

Can anybody confirm this? Or has anyone successfully deployed a
non-classloader-leaking CDI enabled webapp to TomEE?

Regards,
Marcus




--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: Activating CDI creates classloader leak in tomee/tomcat

jgallimore
Thanks for reporting this, along with the sample, the very clear steps for
reproducing the issue, and the analysis. I'll take a look at this later
today - hopefully we can track this down and fix it without too much
trouble.

Jon

On Mon, Oct 14, 2019 at 9:00 AM makkus <[hidden email]> wrote:

> Hi folks,
>
> by tracing down a classloader leak in my webapp I realized, that leaks are
> actually created by activating CDI via adding the "beans.xml" into WEB-INF
> (TomEE plume 8.0.0-M2 and TomEE plume 8.0.0).
> To reproduce, I have created a minimalistic jsf enabled webapp consiting of
> onyl a simple ServletContextListener (called leaktest.AppContextListener).
> Feel free to download the test war archive here:
> https://1drv.ms/u/s!AlHB9FAlFWW_iLJjPO5NAk77apcO4g?e=gjFDoY
>
> When reloading the application inside tomcat multiple times and stopping
> it,
> for each load one leaktest.AppContextListener class reference can be found
> in the heapdump classes
> <http://tomee-openejb.979440.n4.nabble.com/file/t376354/leakWithBeans.jpg>
>
> When renaming "beans.xml" into something invalid like "_beans.xml" the
> classloader leak disappears, only a single leaktest.AppContextListener
> class
> can be found in the heapdump after the app is stopped. Tomcats leak
> detection button confirms this observation. Without CDI enabled (i.e.
> invalid "_beans.xml") the leak message inside the manager app lists only a
> single line (even with repreated reloads). With CDI enabled (valid
> beans.xml) for each reload an new line is added in the leak message window
> of the tomcat web application manager.
>
> Can anybody confirm this? Or has anyone successfully deployed a
> non-classloader-leaking CDI enabled webapp to TomEE?
>
> Regards,
> Marcus
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>
Reply | Threaded
Open this post in threaded view
|

Re: Activating CDI creates classloader leak in tomee/tomcat

makkus
Hi Jon,

would be great to get some support here, thanks so much. I'm still doing
tests on it. The follwing additional clues I got so far:
- adding a @RequestScoped annotation will make my mini-non-leaking app start
leaking.
(here my test code (Netbeans project):  leak2.zip
<http://tomee-openejb.979440.n4.nabble.com/file/t376354/leak2.zip>   )
- often Lambda Expressions will also introduce leaks (see example in code)
- note, that no instances of the webapp classes are on the heap after a stop
- but the classes are still loaded. (Maybe something triggers some other
(external) instance to be loaded with the webappclassloader...?)
I'm afraid I'm lacking substantial experience with this type of profiling,
so I almost become clueless on what else to test.

I'm on Tomee plume 8.0.0 and OpenJDK 11

Marcus





--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: Activating CDI creates classloader leak in tomee/tomcat

makkus
In reply to this post by makkus
No news on this?
It looks to be a some problem in openebj? Is nobody else experiencing class
leaks with TomEE 8? If I investigate the orphaned  if find this:
<http://tomee-openejb.979440.n4.nabble.com/file/t376354/webappLoader_cgRoot.png>
Any ideas what is happening here?



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: Activating CDI creates classloader leak in tomee/tomcat

jgallimore
Sorry, I had a couple of critical issues at work this week. This is next on
my list to look at.

Jon

On Sun, 20 Oct 2019, 11:00 makkus, <[hidden email]> wrote:

> No news on this?
> It looks to be a some problem in openebj? Is nobody else experiencing class
> leaks with TomEE 8? If I investigate the orphaned  if find this:
> <
> http://tomee-openejb.979440.n4.nabble.com/file/t376354/webappLoader_cgRoot.png>
>
> Any ideas what is happening here?
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>
Reply | Threaded
Open this post in threaded view
|

Re: Activating CDI creates classloader leak in tomee/tomcat

jgallimore
Hi

Just to confirm, I can reproduce your issue. Digging into it some more in
VisualVM.

Jon

On Sun, Oct 20, 2019 at 12:17 PM Jonathan Gallimore <
[hidden email]> wrote:

> Sorry, I had a couple of critical issues at work this week. This is next
> on my list to look at.
>
> Jon
>
> On Sun, 20 Oct 2019, 11:00 makkus, <[hidden email]> wrote:
>
>> No news on this?
>> It looks to be a some problem in openebj? Is nobody else experiencing
>> class
>> leaks with TomEE 8? If I investigate the orphaned  if find this:
>> <
>> http://tomee-openejb.979440.n4.nabble.com/file/t376354/webappLoader_cgRoot.png>
>>
>> Any ideas what is happening here?
>>
>>
>>
>> --
>> Sent from:
>> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>>
>