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

IdentityHashMap占用内存大 #849

Closed
waterdream opened this issue Oct 9, 2016 · 5 comments · Fixed by #941
Closed

IdentityHashMap占用内存大 #849

waterdream opened this issue Oct 9, 2016 · 5 comments · Fixed by #941
Milestone

Comments

@waterdream
Copy link

线上代码运行2天后,com.alibaba.fastjson.util.IdentityHashMap内存占用特别大,如果持续运行十几天,会导致内存用完,频繁fullgc。

image

看了一下identityhashmap的内容,相同的key值有很多份,正常情况应该只有一份吧。
image

@wenshao
Copy link
Member

wenshao commented Oct 10, 2016

fastjson什么版本?

@waterdream
Copy link
Author

1.2.14

@wenshao
Copy link
Member

wenshao commented Oct 10, 2016

TypeReference每次都new了?

@waterdream
Copy link
Author

我们的代码是这么使用的。
public static <T> OpenInResponse<T> parse(String text, Class<T> type) { OpenInResponse<T> response = JSON.parseObject(text, new TypeReference<OpenInResponse<T>>(type) { }); if (response == null) { response = OpenInResponse.fail(-1, "unkown_error", text); } return response; }

fastjson的代码里如截图,是每次都new一个出来
image

@waterdream
Copy link
Author

waterdream commented Oct 10, 2016

https://github.com/alibaba/fastjson/wiki/TypeReference 链接给的例子一样的用法

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

Successfully merging a pull request may close this issue.

2 participants