On 06.11.23 18:55, William Crowell wrote:
Good afternoon,
I am running Tomcat 9.0.78 with JDK 1.8.0_371 (running with G1GC), and I am
loading some very large Java classes into Metaspace. I know this is not good
practice, but I inherited this library. These classes have business rules and
are doing some basic primitive and array manipulations, and I am running out of
native memory. I don’t think there are any JNI calls in this code base.
Are there anything existing issues with the Tomcat 9 class loader? I doubt
there are but wanted to check.
Hi William,
when you say "I am loading some very large Java classes into Metaspace.
I know this is not good practice" it does not sound like this inherited
library is using tomcat's standard way of classloading - please clarify.
Also, nothing in that statement points to anything where a leak on
tomcat's side would make a difference: Are you experiencing problems
after reloading a webapp, or just in general operation? You might simply
need to assign more metaspace to the VM for this library to operate
properly.
So, this boils down to:
* How does this library load the classes into memory?
* Do you redeploy?
* What's your metaspace (and general memory) setting, and what are the
conditions under which you run out of memory?
* Do you see any log message that hint at classes that won't be garbage
collected because of stale references? Tomcat issues those warnings, in
case you (for example) start your own background threads that keep
holding the memory allocated to them.
Also: I second your doubt about Tomcat's classloader being the cause for
your problems - unless proven otherwise.
Olaf