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

mirrorCache内存泄露 #1599

Open
xltanglx opened this issue Jun 15, 2022 · 5 comments
Open

mirrorCache内存泄露 #1599

xltanglx opened this issue Jun 15, 2022 · 5 comments

Comments

@xltanglx
Copy link

您好,在org.nutz.lang包下有一个Mirror类,它有一个静态的成员变量mirrorCache,用于缓存Type-Mirror的映射,应用上线后mirrorCache会逐渐增大,如果长期不重启应用,mirrorCache甚至达到了1个GB,我通过NutConf.USE_MIRROR_CACHE=false禁用了mirrorCache,但是之后却报java.lang.ClassCastException异常,但是只要不禁用mirrorCache就没有问题,所以想请教一下,正确禁用mirrorCache的姿势是什么?我们是SpingBoot应用。

@wendal
Copy link
Member

wendal commented Jun 20, 2022

java.lang.ClassCastException ? 给一下日志或者重现代码

@xltanglx
Copy link
Author

xltanglx commented Jun 23, 2022

首先感谢您的回复,以下是一个简单的复现代码,当NutConf.USE_MIRROR_CACHE=true时无问题,但是NutConf.USE_MIRROR_CACHE=false时,最后一行出现类型转换异常。
NutConf.USE_MIRROR_CACHE = false; String jsonStr = "{\"groupName\":\"终极一班\",\"students\":[{\"name\":\"张三\",\"age\":15},{\"name\":\"李四\",\"age\":15}]}"; Group group = Json.fromJson(Group.class, jsonStr); List<Student> students = group.getStudents(); Student student = Lang.first(students);

@xltanglx
Copy link
Author

xltanglx commented Jun 23, 2022

Nutz似乎识别不出来List放的是Student,而是把它当做一个LinkedHashMap,所以出现java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to Student

@wendal
Copy link
Member

wendal commented Jun 23, 2022

哦, json报错, 这个没想到

@xltanglx
Copy link
Author

请问Nutz会修复这个漏洞吗?如果没有修复,可能mirrorCache带来的内存泄露没有办法解决。除此之外,想问一下,为什么关闭mirrorCache会影响到Json的序列化,关闭mirrorCache还会影响到其他工具吗?

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

2 participants