Groovy update causing a ton of dead GroovyClassLoaders in PermGen

假装没事ソ 提交于 2019-12-01 11:59:55

i had same problem when using groovy script for compiling and running. I finally work out with these way: 1. if you work with java version under 7 , you can use codes below to clean your class after compiled

 public static void clearAllClassInfo(Class<?> type) throws Exception {
    Field globalClassValue = ClassInfo.class.getDeclaredField("globalClassValue");
    globalClassValue.setAccessible(true);
    GroovyClassValue classValueBean = (GroovyClassValue) globalClassValue.get(null);
    classValueBean.remove(type);
}

2. otherwise you are lucky, because you just need add an properties in SystemProperties

-Dgroovy.use.classvalue=true

We've had similar issues with a file parser written in groovy, memory leaks like a seave - when you do a lot of String manipulation. We also tried the clearCache() on the classloader and also .removeMetaClass() with no use.

We finally got around this problem by compiling the groovy module as a jar file and including it in the project.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!