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.