You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jmeter.apache.org by bu...@apache.org on 2016/08/05 03:52:40 UTC

[Bug 59946] New: Memory leak at JSR223 components with Groovy script

https://bz.apache.org/bugzilla/show_bug.cgi?id=59946

            Bug ID: 59946
           Summary: Memory leak at JSR223 components with Groovy script
           Product: JMeter
           Version: 3.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Main
          Assignee: issues@jmeter.apache.org
          Reporter: Teemu.Vesala@qentinel.com

Created attachment 34103
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34103&action=edit
Sample test file to show memory leak

I noticed that there is major increase at memory usage when JSR223 components
are used without caching the compiled script. The attached test script contains
only JSR223 sampler with script "def x = 1 + 1" which should not leak memory.
But if you execute it, you quickly notice that it increases the memory usage.

This does not affect to JMeter if the compiled script is cached. So I recommend
it, but still this can be an issue.

The dump shows that the leaked elements are
org.codehaus.groovy.reflection.ClassInfo. I've attached Eclipse MAT rerpot as
ZIP package. 

I've experimented and investiaged multiple solutions. I've attached an example
solution for JSR223Sampler.java, but I'm not sure if this solution is
acceptable. Basically the problem is, that when we create new script engine
ScriptEngineManager.getEngineByName(lang), the Groovy engine loses its cache
reference, but still adds the information about the script to cache. For that
reason it creates new script to cache each time when the script is executed.
This at the end fills the memory with the Groovy's ClassInfo. 

Based to the answer abotu thread safety of Groovy
(http://stackoverflow.com/questions/30140103/should-i-use-a-separate-scriptengine-and-compiledscript-instances-per-each-threa),
only single ScriptEngine could be created for all threads. But does that cause
problems with other script engines? 

This same issue is with pre- and post-processor, and I suppose it is with all
other JSR223 elements also.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59946] Memory leak at JSR223 components with Groovy script due to Groovy Memory leak when not caching compiled script

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59946

Philippe Mouawad <p....@ubik-ingenierie.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #8 from Philippe Mouawad <p....@ubik-ingenierie.com> ---
Nothing more can be done in JMeter for this.
Documentation updated to mention issue.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59946] Memory leak at JSR223 components with Groovy script due to Groovy Memory leak

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59946

Philippe Mouawad <p....@ubik-ingenierie.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Memory leak at JSR223       |Memory leak at JSR223
                   |components with Groovy      |components with Groovy
                   |script                      |script due to Groovy Memory
                   |                            |leak
           Hardware|PC                          |All

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59946] Memory leak at JSR223 components with Groovy script due to Groovy Memory leak when not caching compiled script

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59946

--- Comment #7 from Philippe Mouawad <p....@ubik-ingenierie.com> ---
@Dev Team, should we set in system.properties:

-Dgroovy.use.classvalue=true

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59946] Memory leak at JSR223 components with Groovy script due to Groovy Memory leak when not caching compiled script

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59946

--- Comment #5 from Philippe Mouawad <p....@ubik-ingenierie.com> ---
(In reply to Philippe Mouawad from comment #3)
> Hello,
> First thanks a lot for the report, the investigation and your work.
> 
> I read it and I wonder if you're not facing this:
> 
> - http://www.groovy-lang.org/mailing-lists.html#nabble-td387931
Ignore this
> 
> Could you clarify a bit more how this thread
> (http://stackoverflow.com/questions/30140103/should-i-use-a-separate-
> scriptengine-and-compiledscript-instances-per-each-thread) relates to this
> issue ? Is it because of null being returned by
> http://docs.oracle.com/javase/8/docs/api/javax/script/ScriptEngineFactory.
> html#getParameter-java.lang.String-
> 
> 
> I will have further look but I wonder if anything can be done about that if
> it's how groovy works.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59946] Memory leak at JSR223 components with Groovy script

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59946

--- Comment #4 from Philippe Mouawad <p....@ubik-ingenierie.com> ---
Hi Again,
I reproduced your issue and got a Heap Dump.

It seems we are facing Groovy bug :

- https://issues.apache.org/jira/browse/GROOVY-7683 (which is in progress)
- https://issues.apache.org/jira/browse/GROOVY-7591 (which is fixed)

It mentions a workaround which is to set "-Dgroovy.use.classvalue=true" 

This flag is introduced as a (hopefully) temporary workaround for a JVM bug,
that is to say that using
ClassValue prevents the classes and classloaders from being unloaded.
ee https://bugs.openjdk.java.net/browse/JDK-8136353

Groovy team says for bug GROOVY-7591 that issue is due to JDK Bug:

- https://bugs.openjdk.java.net/browse/JDK-8136353

I tried the settings and it works.

What do you think ?

Thanks for feedback

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59946] Memory leak at JSR223 components with Groovy script due to Groovy Memory leak when not caching compiled script

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59946

--- Comment #6 from Philippe Mouawad <p....@ubik-ingenierie.com> ---
Author: pmouawad
Date: Wed Aug 10 06:40:35 2016
New Revision: 1755674

URL: http://svn.apache.org/viewvc?rev=1755674&view=rev
Log:
Bug 59946 - Memory leak at JSR223 components with Groovy script due to Groovy
Memory leak when not caching compiled script
Document workaround
Bugzilla Id: 59946

Modified:
    jmeter/trunk/xdocs/usermanual/component_reference.xml

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59946] Memory leak at JSR223 components with Groovy script

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59946

Philippe Mouawad <p....@ubik-ingenierie.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |p.mouawad@ubik-ingenierie.c
                   |                            |om
             Status|NEW                         |NEEDINFO

--- Comment #3 from Philippe Mouawad <p....@ubik-ingenierie.com> ---
Hello,
First thanks a lot for the report, the investigation and your work.

I read it and I wonder if you're not facing this:

- http://www.groovy-lang.org/mailing-lists.html#nabble-td387931

Could you clarify a bit more how this thread
(http://stackoverflow.com/questions/30140103/should-i-use-a-separate-scriptengine-and-compiledscript-instances-per-each-thread)
relates to this issue ? Is it because of null being returned by
http://docs.oracle.com/javase/8/docs/api/javax/script/ScriptEngineFactory.html#getParameter-java.lang.String-


I will have further look but I wonder if anything can be done about that if
it's how groovy works.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59946] Memory leak at JSR223 components with Groovy script

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59946

--- Comment #2 from Teemu Vesala <Te...@qentinel.com> ---
Created attachment 34105
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34105&action=edit
Example of non leaking JSR223Sampler - not the full solution

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59946] Memory leak at JSR223 components with Groovy script

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59946

--- Comment #1 from Teemu Vesala <Te...@qentinel.com> ---
Created attachment 34104
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34104&action=edit
MAT results for the leak

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59946] Memory leak at JSR223 components with Groovy script due to Groovy Memory leak when not caching compiled script

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59946

Philippe Mouawad <p....@ubik-ingenierie.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Memory leak at JSR223       |Memory leak at JSR223
                   |components with Groovy      |components with Groovy
                   |script due to Groovy Memory |script due to Groovy Memory
                   |leak                        |leak when not caching
                   |                            |compiled script
           Priority|P2                          |P4

-- 
You are receiving this mail because:
You are the assignee for the bug.