[ https://issues.apache.org/jira/browse/GROOVY-8189?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16025940#comment-16025940 ]
Jochen Kemnade commented on GROOVY-8189: ---------------------------------------- The second case is not relevant for my use case as my scripts are completely independent. Using separate ClassLoaders should do the trick. I wonder if there's a way to solve this anyway. {{GroovyClassLoader.removeClassCacheEntry(className)}} could also remove all entries that start with {{"$className\$"}}. Or it could keep track of the classes that were compiled for which root script class. I still wonder if {{InvokerHelper.removeClass(clazz)}} should call {{clazz.classLoader.removeClassCacheEntry(clazz.name)}}. > OutOfMemoryError with groovy.use.classvalue=false > ------------------------------------------------- > > Key: GROOVY-8189 > URL: https://issues.apache.org/jira/browse/GROOVY-8189 > Project: Groovy > Issue Type: Bug > Affects Versions: 2.4.11 > Reporter: Jochen Kemnade > > The following script causes an OOME. > {code} > def classLoader = new groovy.lang.GroovyClassLoader() > while(true){ > def clazz = classLoader.parseClass(' ') > org.codehaus.groovy.runtime.InvokerHelper.removeClass(clazz) > } > {code} > If I run the script with {{-Dgroovy.use.classvalue}}, the OOME does not occur. > The heap dump shows a lot of {{HashMap}} entries, most of them related to > {{GroovyClassLoader}}'s {{classCache}}. > {noformat} > this - value: java.util.HashMap$Node[] #361 > <- table - class: java.util.HashMap, value: java.util.HashMap$Node[] #361 > <- permsMap - class: java.security.Permissions, value: > java.util.HashMap #858 > <- permissions - class: java.security.ProtectionDomain, value: > java.security.Permissions #103 > <- value - class: java.util.HashMap$Node, value: > java.security.ProtectionDomain #231 > <- [8] - class: java.util.HashMap$Node[], value: > java.util.HashMap$Node #751 > <- table - class: java.util.HashMap, value: > java.util.HashMap$Node[] #362 > <- pdcache - class: groovy.lang.GroovyClassLoader$InnerLoader, > value: java.util.HashMap #854 > <- <classLoader> - class: script149484505219332, value: > groovy.lang.GroovyClassLoader$InnerLoader #100 > <- value - class: java.util.HashMap$Node, value: > script149484505219332 class script149484505219332 > <- [2709] - class: java.util.HashMap$Node[], value: > java.util.HashMap$Node #753 > <- table - class: java.util.HashMap, value: > java.util.HashMap$Node[] #11647 > <- classCache (Java frame) - class: > groovy.lang.GroovyClassLoader, value: java.util.HashMap #5463 > {noformat} -- This message was sent by Atlassian JIRA (v6.3.15#6346)