-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
new ExpressRunner() 导致内存泄漏 #312
Comments
本来就应该是用单例模式
…---- 回复的原邮件 ----
| 发件人 | ***@***.***> |
| 发送日期 | 2024年01月30日 16:23 |
| 收件人 | alibaba/QLExpress ***@***.***> |
| 抄送人 | Subscribed ***@***.***> |
| 主题 | [alibaba/QLExpress] new ExpressRunner() 导致内存泄漏 (Issue #312) |
线上使用时发现执行ql表达式会产生较严重的内存泄漏,老年代一直增长。原因是每次执行都new一次ExpressRunner(),改成全局变量就好了。请问问为什么新建ExpressRunner会出现内存泄漏。
简单demo:
public class ExpressMain {
public static ExpressRunner runner = new ExpressRunner();
public static void demo1() throws Exception {
ExpressRunner runner = new ExpressRunner();
runner.setIgnoreConstChar(true);
DefaultContext<String, Object> context = new DefaultContext<String, Object>();
context.put("package_order_cnt_json","234");
context.put("finishOrderDiscountRate",80);
context.put("c",3);
String express = " (package_order_cnt_json!= null and (package_order_cnt_json like '%269%' or package_order_cnt_json like '%234%' or package_order_cnt_json like '%111%' or package_order_cnt_json like '%333%' or package_order_cnt_json like '%22%' or package_order_cnt_json like '%5564%' or package_order_cnt_json like '%43%'))\n";
Object execute = runner.execute(express, context, null, true, false);
System.out.println(execute);
}
public static void main(String[] args) throws Exception {
while (true) {
demo1();
}
}
}
image.png (view on web)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
那需要并行计算多组表达式,但各组间包含不同宏定义、操作符的情况怎么解决? 宏定义不能像上下文那样在执行表达式时传入,必须设置在runner上。 并且这些宏定义分组还是由决策平台客户端决定的,不能初始化为固定数量的runner单例。 如果以分组粒度去动态创建runner的话,又会出现题主所说的内存泄漏问题。 |
版本:3.3.2 @Test
public void testWhile() throws Exception {
while (true) {
ExpressRunner runner = new ExpressRunner();
runner.setIgnoreConstChar(true);
DefaultContext<String, Object> context = new DefaultContext<String, Object>();
context.put("package_order_cnt_json","234");
context.put("finishOrderDiscountRate",80);
context.put("c",3);
String express = " (package_order_cnt_json!= null and (package_order_cnt_json like '%269%' or package_order_cnt_json like '%234%' or package_order_cnt_json like '%111%' or package_order_cnt_json like '%333%' or package_order_cnt_json like '%22%' or package_order_cnt_json like '%5564%' or package_order_cnt_json like '%43%'))\n";
Object execute = runner.execute(express, context, null, true, false);
System.out.println(execute);
}
} |
runner.execute(express, context, null, true, false); 你这个用例,倒数第二个参数应该填false, 或者执行完毕后执行一下这个 runner.clearExpressCache() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
线上使用时发现执行ql表达式会产生较严重的内存泄漏,老年代一直增长。原因是每次执行都new一次ExpressRunner(),改成全局变量就好了。请问问为什么新建ExpressRunner会出现内存泄漏。
简单demo:
public class ExpressMain {
}
The text was updated successfully, but these errors were encountered: