Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
None
-
None
-
None
Description
Many groovy users have encountered the OOME while parseClass(scriptText) even if the scriptText has not been changed.
The cause of the issue is the script file name is generated via System.currentTimeMillis(), so the script file name will change even if the script text is not changed. As a result, many class instances are created and cached in groovy.lang.GroovyClassLoader#classCache, the classes can not be GCed, which causes OOME.
The solution is very simple, the script file name could be generated via md5, which will not change if the script text is not changed.
def gcl = new GroovyClassLoader() while (true) { gcl.parseClass('def x = 1') }
Error message:
java.lang.OutOfMemoryError: Compressed class space
at ConsoleScript6.run(ConsoleScript6:4)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Attachments
Issue Links
- links to