groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7646) Classes generated by Eval() never collected from Permgen/Metaspace
Date Tue, 11 Oct 2016 12:43:20 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-7646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15565317#comment-15565317
] 

ASF GitHub Bot commented on GROOVY-7646:
----------------------------------------

Github user jochenberger commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/445#discussion_r82783539
  
    --- Diff: src/main/groovy/lang/GroovyClassLoader.java ---
    @@ -969,13 +970,24 @@ public Void run() {
          */
         public void clearCache() {
             synchronized (classCache) {
    +            for (Class cl : classCache.values()) {
    +                InvokerHelper.removeClass(cl);
    +            }
                 classCache.clear();
             }
             synchronized (sourceCache) {
                 sourceCache.clear();
             }
         }
     
    +    @Override
    +    public void close() throws IOException {
    +        super.close();
    +        for (Class cl : classCache.values()) {
    --- End diff --
    
    I thought that synchronization might not be an issue since we are `close`-ing the ClassLoader
anyway and I wanted to avoid the additional cost of synchronizing over and clearing `sourceCache`.
But I guess it's better safe than sorry, so I made the change.


> Classes generated by Eval() never collected from Permgen/Metaspace
> ------------------------------------------------------------------
>
>                 Key: GROOVY-7646
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7646
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.4.5
>         Environment: Oracle jdk8u51 and jdk8u66
>            Reporter: Isaac Dooley
>
> It seems classes generated by Eval() are never collected, thus causing PermGen or Metaspace
to fill up and the JVM to hang/crash.
> Reproduce by running the following code, after setting java option {{-XX:MaxMetaspaceSize=50m}}.

> {code}
> 100000.times{ x -> assert 10 == Eval.x(2, 'x * 4 + 2;') }
> {code}
> After about 2700 calls to Eval the program will crash with OutOfMemoryError, 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message