You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Bharath Ganesh <bh...@pramati.com> on 2007/03/13 09:26:32 UTC
Some Memory Leaks : (Registry, Threadlocal not cleared)
Hi
I could see that when an endpoint is published, the corresponding org.apache.cxf.endpoint.ServerImpl instance is registered with the ServerRegistry. I wanted to know the reason for this. As far as I could not see there are no accessors for this registry.
During endpoint.stop(), the ServerImpl is not cleared from the Registry. This leads to strong reference of the ServerImpl, which would in-turn hold a reference to JaxWsEndpointImpl, the observer and all related stuff.
Also, even after stopping the endpoint (endpoint.stop() ) , if I get the list of services (cxf/services) it still dispalys the serivce. (It cant be accessed since there wont be any observer)
Another memory leak that I could see is in the ThreadLocal in WebserviceContextImpl. During web service invocation, the context threadlocal is set but never cleared. I think the threadlocal should be cleared at the end of invoke() method in JaxWsMethodInvoker.
Please clarify.
cheerio
Bharath
Re: Some Memory Leaks : (Registry, Threadlocal not cleared)
Posted by Bharath Ganesh <bh...@pramati.com>.
Hi Willem,
I understand the ThreadLocal will be cleared when the servicing thread dies or when setMessageContext is called again.
But since the servicing thread here is a Web Worker thread, the thread is pooled and stays alive as long as the web server is alive.
So, if there are 100 worker threads, assume each of them had serviced a web service request, each of them would hold a MessageContext, which would inturn hold a reference to the SOAPMessageImpl (in turn to the CXFBus->All ServerImpl's) for the entire lifetime of server.
Which means this needs to be fixed:-)
Anyways I have logged a bug: https://issues.apache.org/jira/browse/CXF-457
For the ServerRegistry leak: https://issues.apache.org/jira/browse/CXF-458
cheerio
Bharath
----- Original Message -----
From: Willem Jiang
To: cxf-dev@incubator.apache.org
Cc: Deepak
Sent: Tuesday, March 13, 2007 3:14 PM
Subject: Re: Some Memory Leaks : (Registry, Threadlocal not cleared)
Hi Bharath,
Thank you for the code review.
The ServerRegistry just work for calling the endpointImpl's shutdown
method when the CXFBus.shutdown is called, and ServerRegistry also
provids the Service list info for management.
I agree you to call the ServerRegistry's unregister method when the
endpointImpl's shutdown is called to avoid the ServerRegistry's memory leak.
I don't think the ThreadLocal variable will case the memory leaks.
Because it is a static variable and this variable will be set by calling
the WebserviceContextImpl's setMessageContext method.
The context will be GC if the thread is destoried or setMessageContext
is called again.
Cheers,
Willem.
Bharath Ganesh wrote:
>Hi
>
>I could see that when an endpoint is published, the corresponding org.apache.cxf.endpoint.ServerImpl instance is registered with the ServerRegistry. I wanted to know the reason for this. As far as I could not see there are no accessors for this registry.
>
>During endpoint.stop(), the ServerImpl is not cleared from the Registry. This leads to strong reference of the ServerImpl, which would in-turn hold a reference to JaxWsEndpointImpl, the observer and all related stuff.
>
>Also, even after stopping the endpoint (endpoint.stop() ) , if I get the list of services (cxf/services) it still dispalys the serivce. (It cant be accessed since there wont be any observer)
>
>Another memory leak that I could see is in the ThreadLocal in WebserviceContextImpl. During web service invocation, the context threadlocal is set but never cleared. I think the threadlocal should be cleared at the end of invoke() method in JaxWsMethodInvoker.
>
>Please clarify.
>
>cheerio
>Bharath
>
>
Re: Some Memory Leaks : (Registry, Threadlocal not cleared)
Posted by Willem Jiang <ni...@iona.com>.
Hi Bharath,
Thank you for the code review.
The ServerRegistry just work for calling the endpointImpl's shutdown
method when the CXFBus.shutdown is called, and ServerRegistry also
provids the Service list info for management.
I agree you to call the ServerRegistry's unregister method when the
endpointImpl's shutdown is called to avoid the ServerRegistry's memory leak.
I don't think the ThreadLocal variable will case the memory leaks.
Because it is a static variable and this variable will be set by calling
the WebserviceContextImpl's setMessageContext method.
The context will be GC if the thread is destoried or setMessageContext
is called again.
Cheers,
Willem.
Bharath Ganesh wrote:
>Hi
>
>I could see that when an endpoint is published, the corresponding org.apache.cxf.endpoint.ServerImpl instance is registered with the ServerRegistry. I wanted to know the reason for this. As far as I could not see there are no accessors for this registry.
>
>During endpoint.stop(), the ServerImpl is not cleared from the Registry. This leads to strong reference of the ServerImpl, which would in-turn hold a reference to JaxWsEndpointImpl, the observer and all related stuff.
>
>Also, even after stopping the endpoint (endpoint.stop() ) , if I get the list of services (cxf/services) it still dispalys the serivce. (It cant be accessed since there wont be any observer)
>
>Another memory leak that I could see is in the ThreadLocal in WebserviceContextImpl. During web service invocation, the context threadlocal is set but never cleared. I think the threadlocal should be cleared at the end of invoke() method in JaxWsMethodInvoker.
>
>Please clarify.
>
>cheerio
>Bharath
>
>