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

@SpringAware annotation leads to memory leak #470

Closed
ghost opened this issue Apr 29, 2013 · 1 comment

Comments

Projects
None yet
1 participant
@ghost
Copy link

commented Apr 29, 2013

Hi,

We are using distributed executor service to process a lot of tasks which look like:

@SpringAware
public abstract class PlayerTaskBase implements PartitionAware, Serializable {
@resource(name = "playerService")
private transient PlayerService playerService;
// a lot more spring beans injected here
}

and it leads to memory leak by adding cacheKey) to nonAdvisedBeans set in class AbstractAutoProxyCreator, which are not removed after that.
Example of cacheKey string:
"com.playtech...task.IncreaseBalanceTask_com.playtech...task.IncreaseBalanceTask#11932"

That is invoked from SpringManagedContext class.
private Object initializeIfSpringAwareIsPresent(Object obj) {
Class clazz = obj.getClass();
if (clazz.isAnnotationPresent(SpringAware.class)) {
final String name = clazz.getName() + "#" + idGen.incrementAndGet();
beanFactory.autowireBean(obj);
obj = beanFactory.initializeBean(obj, name);
}
return obj;
}

At this moment I see only one way - do not use injecting beans by using spring and to handle it manually.
Could you suggest other solution how to avoid this leak or how to deal with it?

Found in hazelcast-spring:2.5

@mdogan

This comment has been minimized.

Copy link
Member

commented May 2, 2013

Line 'String name = clazz.getName() + "#" + idGen.incrementAndGet()' is to
make bean name unique in Spring context. But according to Spring docs, that
name is only used for callback handling. So, in the next patch I'll convert
it to just 'String name = clazz.getName()'. That way there will be only one
record per class.

Thanks for reporting.

@mmdogan

@mdogan mdogan closed this in 13960bc May 2, 2013

@ghost ghost assigned mdogan May 2, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.