We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
代码中使用姿势大致如下: ParameterizedTypeImpl type = new ParameterizedTYpeImpl(new Type[]{ SomeInfo.class }, null, CommonVO.class); CommonVO result = (CommonVO)JSON.parseObject(jsonString, type);
原因: com.alibaba.fastjson.ParserConfig定义一个字段用于缓存不同类的反序列化器,使用的是IdentityHashMap(IdentityHashMap使用的是==比较key的值,不同于HashMap使用equals比较),缓存是以Type为key: private final IdentityHashMap<Type, ObjectDeserializer> deserializers = new IdentityHashMap<Type, ObjectDeserializer>();
随着系统的运行,ParserConfig的deserializers(IdentityHashMap类型)内存占用越来越大,造成内存泄漏。
The text was updated successfully, but these errors were encountered:
Add test case, alibaba#3329
25d7be0
IdentityHashMap 里面的 buckets size 是固定的,所以不会越来越大
Sorry, something went wrong.
buckets size 是固定的,但是链式map可以继续增加对象数量
使用ParameterizedTypeImpl,需要单例使用,这种方式是有问题的
软件开放出来的东西如果用起来有问题就是bug,否则可以把这个类设置成protect
38070ca
wenshao
No branches or pull requests
代码中使用姿势大致如下:
ParameterizedTypeImpl type = new ParameterizedTYpeImpl(new Type[]{ SomeInfo.class }, null, CommonVO.class);
CommonVO result = (CommonVO)JSON.parseObject(jsonString, type);
原因:
com.alibaba.fastjson.ParserConfig定义一个字段用于缓存不同类的反序列化器,使用的是IdentityHashMap(IdentityHashMap使用的是==比较key的值,不同于HashMap使用equals比较),缓存是以Type为key:
private final IdentityHashMap<Type, ObjectDeserializer> deserializers = new IdentityHashMap<Type, ObjectDeserializer>();
随着系统的运行,ParserConfig的deserializers(IdentityHashMap类型)内存占用越来越大,造成内存泄漏。
The text was updated successfully, but these errors were encountered: