-
Notifications
You must be signed in to change notification settings - Fork 859
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
Add additional groovy classloaders to ignore list. #7460
Add additional groovy classloaders to ignore list. #7460
Conversation
@@ -110,7 +110,9 @@ private static void configureIgnoredTypes(IgnoredTypesBuilder builder) { | |||
|
|||
private static void configureIgnoredClassLoaders(IgnoredTypesBuilder builder) { | |||
builder | |||
.ignoreClassLoader("groovy.lang.GroovyClassLoader") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know when/in what cases the GroovyClassLoader
is used? Looks like all our groovy tests are passing, which probably means it's not being used there. Does excluding it here mean that all groovy apps (like e.g. grails apps) will no longer be instrumented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is used when the groovy script is compiled on the fly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know when/in what cases the GroovyClassLoader is used?
I'm not sure of all the cases, but in the sample code above it is used. @laurit is probably right here.
@breedx-splk i tried running the snipped you provided with current agent and |
That's surprising to me. I'm not sure if it will explode 256m, but I would have kinda expected it to. From memory -- The thing to do is to insert a sleep after the loop and while it's paused take a heap dump and look at the leaky classloaders. |
how are we holding onto these class loaders? generally we only hold weak references to class loaders |
I ran it again and confirmed that they are indeed weak references in the cache. So the original "holding onto memory" I guess is overstating it. In this (contrived) example nearly all the memory is held by the classloaders in the cache, but in a more normal application I guess application memory usage will cause the cache to shrink and this isn't actually a problem? |
Eclipse memory analyzer removes unreachable objects from the dump. If we have a weak reference to a class loader that is otherwise unreachable it will show up in the dump. I guess this could leave an impression that the agent is increasing the heap usage, although the same objects are around even without the agent, they are just hidden form your view. In https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/tag/v1.21.0 we had a change to clear weak maps from a background thread, this could help with some agent memory usage issues. If this issue has roots in a real world application exhibiting high memory usage because of the agent then I'd suggest trying with the latest agent. |
👍 |
Groovy apps that parse a lot of scripts can generate a lot of classloaders that will ultimately end up causing the agent to cache a LOT of memory. For example, some java code that uses the Gremlin groovy script engine to dynamically create and execute scripts can reproduce this:
I have manually confirmed that ignoring the groovy classloaders (in this PR) prevent the agent from exploding the cache and holding onto memory. I could use another brain in deciding if there could be other unintended consequences.