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

apollo SpringValueRegistry不释放引用触发full gc #1670

Closed
shanjingheng opened this issue Nov 15, 2018 · 2 comments · Fixed by #1676
Closed

apollo SpringValueRegistry不释放引用触发full gc #1670

shanjingheng opened this issue Nov 15, 2018 · 2 comments · Fixed by #1676

Comments

@shanjingheng
Copy link

shanjingheng commented Nov 15, 2018

jdk版本 1.8.0_102
 
写个了程序验证了下使用@value的对象是不会被回收的,若是多例的情况下,就会造成很多对象无法回收。 是否需要将bean改成弱引用,或若不需要onchange的功能,有开关设置不存储
for (String key : keys) {
SpringValue springValue = new SpringValue(key, value.value(), bean, beanName, field, false);
springValueRegistry.register(key, springValue);
logger.debug("Monitoring {}", springValue);
}

image

image

@shanjingheng shanjingheng changed the title apollo SpringValueRegistry占用内存过大导致频繁触发full gc apollo SpringValueRegistry不释放引用触发full gc Nov 15, 2018
@nobodyiam
Copy link
Member

  1. spring value目前是会用强引用hold住bean的,不过一般Spring中bean不会频繁创建的,所以之前有考虑过改为弱引用,只是觉得没有很大必要,不过后续这个确实可以做一下。

  2. 目前是有开关来控制是否需要自动更新spring中注入的值得,参见3.2.2 Spring Placeholder的使用

@nobodyiam
Copy link
Member

@shanjingheng

PR #1676 已经修复该问题

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

Successfully merging a pull request may close this issue.

2 participants