You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by "jeremie.brebec@gmail.com" <je...@gmail.com> on 2016/09/09 16:12:23 UTC

Category and memory leak

Hello,

I noticed a strange behavior with my use of Groovy categories. If I execute the unit test [1], the jvm heap and permgen space size don't change, but the memory used by the java process keep growing. After several hours, this process take more than 1g.

I haven't seen any discussion or issues on this subject, and it's maybe not "the good way" to use category. In my real usecase, I want to execute an external callback (defined in groovy with a closure), and this callback is executed with a category in order to help with some complex classes.

This test is executed in Windows 7, with a JRE 1.7.0_80, but this issue is reproduced too in production on Linux, with openjdk 1.7.0_91.

Thanks !

[1]
public class TestCat {

  public static class A {
  }

  @Test
  public void testCategory() {
    for(;;) {
      GroovyCategorySupport.use(A.class, new Closure<Object>(null) {
        public Object call() {
          return null;
        }
      });
    }
  }
}