You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (Jira)" <ji...@apache.org> on 2019/12/12 23:37:00 UTC
[jira] [Resolved] (GROOVY-9329) OOME raised while
`parseClass(scriptText)`
[ https://issues.apache.org/jira/browse/GROOVY-9329?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Sun resolved GROOVY-9329.
--------------------------------
Fix Version/s: (was: 2.5.9)
Resolution: Fixed
> OOME raised while `parseClass(scriptText)`
> ------------------------------------------
>
> Key: GROOVY-9329
> URL: https://issues.apache.org/jira/browse/GROOVY-9329
> Project: Groovy
> Issue Type: Bug
> Reporter: Daniel Sun
> Assignee: Daniel Sun
> Priority: Critical
> Fix For: 3.0.0-rc-3
>
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> 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.
> {code:java}
> def gcl = new GroovyClassLoader()
> while (true) {
> gcl.parseClass('def x = 1')
> }
> {code}
> Error message:
> {code:java}
> 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)
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)