1
votes

I am running some tests using JMeter 3.1. Some of these tests use a JSR223 Sampler that uses Groovy script to evaluate values and return results.

These tests are run from a client using Java 8, update 112.

When I run these tests, the heap memory progressively increases up to the point to provoke an Out of Memory exception and a heap dump.

I've used Java VisualVM to check the progress of memory, and have found out that Loaded Classes continuously increase, up to the point of 100K+ classes loaded.

Thus, I've run JMeter using -verbose:classes, and there are thousand of lines regarding loading "Script" classes like:

[Loaded Script1 from file: /groovy/script]
[Loaded Script2 from file: /groovy/script]
[Loaded Script3 from file: /groovy/script]
[...]
[Loaded Script2409 from file: /groovy/script]

And so on.

Is there any way to avoid such behaviour? I believe JMeter creates a new class definition for every time a script is checked, and those clases never seem to be unloaded from memory.

All these checks are done by using:

evaluate(new File("...\script.groovy"))

I haven't done the script.groovy file myself but can check it if needed to.

Edit: I've tried with a brand new test with an empty groovy script and the class loading is exactly the same, so it has nothing to do with the content of the script.

1

1 Answers

1
votes

This is an issue with version of groovy used in JMeter 3.1.

This version of JMeter is now pretty old, you should upgrade to JMeter 5.0 or 5.1 (released in few hours from now) which embed more recent versions of Groovy where this issue has been fixed.

See also this on using Groovy

When using Groovy as scripting language and not checking Cache compiled script if available (while caching is recommended), you should set this JVM Property -Dgroovy.use.classvalue=true due to a Groovy Memory leak.

Related links:

If you're looking to learn more about performance testing and JMeter, this book will help you.