-1

I an Currently working on a javaEE project that uses weld Cdi implementations.i wasvassign a task to analyse memory leaks and memory management in our appplication. I am Confuse on following aspect about garbage collector and cdi proxy object. i have Cdi Session scoped LoginController bean. when tow or more than two user login than on doubt respective number of LoginController bean get created.If This Login Controller bean is inject to somer other bean and when that other bean is accessed that a proxy to Login Controller is created and trhe request is processed.No matter how many LoginController is created only single instance of Proxy object of LoginController is Created.

Since LoginController bean get garbage collected when the session timeout.But Proxy to Login Controller is never garbage collected once it is created even id all Login Controller beans get garbage collected . i want to know Why..?

1 Answers1

0

The proxy object is created once at runtime to represent the bean created by CDI. There are references at the session level between the sessions (session id's) and the instances behind each of those proxies. The proxy is what is passed around, and is essentially always there.

This is why, for instance, you need to explicitly destroy dependent scoped beans that you manually inject. Their proxies would be around forever.

John Ament
  • 11,595
  • 1
  • 36
  • 45