Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多次编译导致oom #481

Closed
Thintime opened this issue Jul 27, 2022 · 10 comments
Closed

多次编译导致oom #481

Thintime opened this issue Jul 27, 2022 · 10 comments

Comments

@Thintime
Copy link

aviator 版本 5.3.1,jdk11
代码如下

String express = "let a=math.pow((math.abs(c)+a*10)-100,2)+0.2;if(b==45){return a;}else {return -0.7;}";

    while (true) {
        Expression expression = AviatorEvaluator.compile(express);
        Map<String, Object> env = new HashMap<>();
        env.put("a", 100.3);
        env.put("b", 45);
        env.put("c", -199.100);
        Object result = expression.execute(env);
    }

这个程序执行最终会导致 OutOfMemoryError: Compressed class space

但是我看文档是说expression没有引用之后会触发gc卸载内部类,这个错误是啥原因导致的呢

@killme2008
Copy link
Owner

jdk 11 还没有测试过,我会调查看看

@Thintime
Copy link
Author

Thintime commented Aug 1, 2022

jdk 11 还没有测试过,我会调查看看

1.8经测试,同样有此问题

@killme2008
Copy link
Owner

你是 oracle jdk 吗? 我在 jdk8 测试没有问题

@Thintime
Copy link
Author

Thintime commented Aug 2, 2022

你是 oracle jdk 吗? 我在 jdk8 测试没有问题

open jdk

@LiuXuTaoORZ
Copy link

同5.3.1版本,openjdk 11.0.8.10,因业务需要脚本需要频繁更新迭代。
废弃的缓存已经调用AviatorEvaluatorInstance#nvalidateCache(cacheKey)卸载,但还是会出现OutOfMemoryError: Metaspace

@LiuXuTaoORZ
Copy link

基于上述demo代码,jdk版本切换至1.8.0_101,循环中新增200ms间隔进行测试,发现Metasoace占用还是会缓慢增加直至OOM,headdump中存在大量名称为类似Script_1664349841614_11750的类(最后一位从0开始)。

@killme2008
Copy link
Owner

收到,感谢反馈,有空会去调查下 openjdk

@argan
Copy link

argan commented Oct 8, 2022

openjdk 11 和17 都做了尝试,导致OOM的并不是编译,编译产生的class可以正常清理掉;
但是执行阶段有问题,执行时ThreadLocal中产生了大量的com.googlecode.aviator.runtime.function.LambdaFunction 对象示例,无法GC,最终导致OOM

@killme2008
Copy link
Owner

跟这个 issue 有关系 #494

近期会修复下

@killme2008
Copy link
Owner

5.3.3 发布,应该解决了这个问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants