JDK-8166852 : JavaScript engine eval() method causes JVM Young GC to pauses seconds
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 8
  • Priority: P1
  • Status: Resolved
  • Resolution: Duplicate
  • Submitted: 2016-09-28
  • Updated: 2017-03-08
  • Resolved: 2017-02-24
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
JavaScript engine eval() method causes JVM Young GC to pauses seconds 

import javax.script.*;

public class Test {

  public static void main(String[] args) throws InterruptedException {
   ScriptEngine engine = new
ScriptEngineManager().getEngineByName("nashorn");
   String s = "";
   while (true) {
     try {
       Object o = engine.eval(s);
     } catch (ScriptException e) {
       System.err.println("Error:" + e);
     }
   }
 }
}

run the test case with -XX:+PrintGCDetails -Xms64m -Xmx64m, and it shows
an increasing YG collection time:

0.996: [GC (Allocation Failure) [PSYoungGen: 12288K->3608K(16384K)]
12288K->3616K(61440K)
, 0.0330406 secs] [Times: user=0.64 sys=0.06, real=0.03 secs]
...
71.314: [GC (Allocation Failure) [PSYoungGen: 12288K->0K(16384K)]
14777K->2489K(61440K),
0.0710348 secs] [Times: user=0.10 sys=0.01, real=0.07 secs]
...
164.642: [GC (Allocation Failure) [PSYoungGen: 12288K->0K(16384K)]
14777K->2489K(61440K),
 0.1435001 secs] [Times: user=0.18 sys=0.01, real=0.14 secs]
...
553.083: [GC (Allocation Failure) [PSYoungGen: 12288K->0K(16384K)]
14777K->2489K(61440K),
 2.3574281 secs] [Times: user=8.13 sys=0.37, real=2.36 secs]
Comments
From Kevin's analysis this should be a runtime bug because of the MemberNameTable.
17-02-2017

JDK-8174749 should be the solution to this issue.
10-02-2017