You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Olivier Mengué <om...@oxymel.com> on 2010/03/04 15:36:08 UTC

RE : How to fix memory leak in Axis2/C client?

Samisa Abeysinghe wrote:
>It is hard to tell from the list of methods given. Can you please provide
>the code you are using to test? Then we can profile and see where the leaks
>are.

As you probably expected, no, I can't.

Could you at least tell me if I have a good understanding of the API?
Is it my responsability to free the XML trees used in the SOAP exchange?

Or if it may be a bug such as AXIS2C-1452?

>> * for every call to the service:
>>     - I construct the XML request document:
>>         + axutil_qname_create()
>>         + axiom_element_create_with_qname()
>>         + axiom_element_create(), axiom_element_set_text()
>>     - axis2c_svc_client_send_receive()
>>     - I parse the XML response document:
>>         + axis2c_svc_client_get_http_status_code()
>>         + axis2c_svc_client_get_last_response_has_fault()
>>         + axiom_node_get_n,ext_sibling()
>>         + axiom_node_get_node_type()
>>         + axiom_node_get_data_element(), axiom_node_get_localname(),
>> axiom_node_get_namespace(), axiom_node_get_text()
>>
>>
>> I suspect that either the request XML tree and the response XML tree are
>> not freed,
>> but I've seen nothing in the axis2c_svc_client API to do that.
>>
>> Which function calls are missing to fix my leak?
>>
>> Olivier.
>>

Olivier Mengué
Oxymel, France.

RE: How to fix memory leak in Axis2/C client?

Posted by Hatim Daginawala <Ha...@argodata.com>.
If you are using custom HTTP headers and seeing leaks, let me know. I will write a small test program to demonstrate how I do it. It's a little complex to just write it up.

-----Original Message-----
From: Olivier Mengué [mailto:omengue@oxymel.com] 
Sent: Thursday, March 04, 2010 11:07 AM
To: Apache AXIS C User List
Subject: RE : How to fix memory leak in Axis2/C client?

Hatim Daginawala wrote:
>No harm in trying. I have been using release 1.5 for over a year now in a very high volume environment.

I wanted to avoid to call svc_client_create() for every call because it seems this is where axis2.xml is parsed, dynamic libraries loaded... SOAP is heavy enough, I don't want to add axis2.xml parsing to each call.

>svc_client is not designed to be reused. Here are some of the issues I came across in 1.4/1.5
>
>-          It leaks all over the place - For example HTTP headers, you will have to reset all the headers after each use.

How do you do that?

>-          Default HTTP transport opens socket for every request - you have to use libcurl

Good point. However my project does not requires this. I may get one call per hour, and I fear more random disconnection (from the proxy or the remote server) that would be bring random problems hard to track.

Also I had already enough problems getting updated OpenSSL and zlib on my system (AIX) and building Axis2/C. I did not want to add one more dependency.

>-          libcurl wrapper had some terrible memory leaks - this should be fixed in 1.6
>
>-          axis2c does not have support for proxy, ssl, etc with libcurl transport - there are patches to do this though

I'm using SSL through a proxy with Axis2/C built-in SSL and proxy support (without libcurl). Those feature seems to be available since 1.6.
No really blocking problems so far, except memory leaks, but I have submitted many patches for Axis.

Olivier.


---------------------------------------------------
Confidentiality Notice:  This electronic mail transmission is confidential, 
may be privileged and should be read or retained only by the intended
recipient.  If you have received this transmission in error, please
immediately notify the sender and delete it from your system.

---------------------------------------------------------------------
To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
For additional commands, e-mail: c-user-help@axis.apache.org


RE : How to fix memory leak in Axis2/C client?

Posted by Olivier Mengué <om...@oxymel.com>.
Hatim Daginawala wrote:
>No harm in trying. I have been using release 1.5 for over a year now in a very high volume environment.

I wanted to avoid to call svc_client_create() for every call because it seems this is where axis2.xml is parsed, dynamic libraries loaded... SOAP is heavy enough, I don't want to add axis2.xml parsing to each call.

>svc_client is not designed to be reused. Here are some of the issues I came across in 1.4/1.5
>
>-          It leaks all over the place - For example HTTP headers, you will have to reset all the headers after each use.

How do you do that?

>-          Default HTTP transport opens socket for every request - you have to use libcurl

Good point. However my project does not requires this. I may get one call per hour, and I fear more random disconnection (from the proxy or the remote server) that would be bring random problems hard to track.

Also I had already enough problems getting updated OpenSSL and zlib on my system (AIX) and building Axis2/C. I did not want to add one more dependency.

>-          libcurl wrapper had some terrible memory leaks - this should be fixed in 1.6
>
>-          axis2c does not have support for proxy, ssl, etc with libcurl transport - there are patches to do this though

I'm using SSL through a proxy with Axis2/C built-in SSL and proxy support (without libcurl). Those feature seems to be available since 1.6.
No really blocking problems so far, except memory leaks, but I have submitted many patches for Axis.

Olivier.

Re: How to fix memory leak in Axis2/C client?

Posted by Selvaratnam Uthaiyashankar <ut...@gmail.com>.
On Fri, Mar 5, 2010 at 5:51 AM, Samisa Abeysinghe <sa...@wso2.com> wrote:
>
>
> On Fri, Mar 5, 2010 at 2:29 AM, Hatim Daginawala
> <Ha...@argodata.com> wrote:
>>
>> First of all let me say, I did not mean to offend anyone, undermine the
>> work you do or even complain. If I did, I am sorry.
>
> Sure, I was purely trying to make sure that other users do not misunderstand
> anything.
> And, of course if there are leaks, we got to fix them.
>>
>> Axis is great product and I am using axis2c in a production environment
>> and I am very grateful. Thank you.
>>
>>
>>
>> The reason I say it’s not designed for reuse it precisely because it opens
>> connection on every request. I had to switch to libcurl because I was
>> running out of sockets.
>
> We need to explore this more to find the problem.
> One of the reasons that we wrote libcurl transport was to benefit from the
> power of the library. We need to admit, transport libs is not our key
> strength, rather SOAP engine aspects.
> I think it has been some time since we put some effort to look into
> improving libcurl support.
>>
>> When I  developed my code for 1.4, I did ran into various memory leaks and
>> I did submit patches for it. However, I was able to work around most issues.
>> 1.6 might not have those same issues.
>
> We might want to revisit these in 1.7


+1. Lets have a look at libcurl before 1.7 release.

Regards,
Shankar


> Samisa...
>
>>
>>
>>
>> From: Samisa Abeysinghe [mailto:samisa@wso2.com]
>> Sent: Thursday, March 04, 2010 11:16 AM
>>
>> To: Apache AXIS C User List
>> Subject: Re: How to fix memory leak in Axis2/C client?
>>
>>
>>
>>
>>
>> On Thu, Mar 4, 2010 at 9:51 PM, Hatim Daginawala
>> <Ha...@argodata.com> wrote:
>>
>> No harm in trying. I have been using release 1.5 for over a year now in a
>> very high volume environment.
>>
>>
>>
>> svc_client is not designed to be reused.
>>
>>
>>
>> This is an incorrect statement. We reuse it, and it can be re-used.
>>
>> Here are some of the issues I came across in 1.4/1.5
>>
>> -          It leaks all over the place - For example HTTP headers, you
>> will have to reset all the headers after each use.
>>
>>
>>
>> I do not agree with this either. It does not leak all over the place. It
>> sounds almost as if we have not done anything to fix leaks.
>> This certainly is a misinterpretation and understatement.
>>
>> -          Default HTTP transport opens socket for every request – you
>> have to use libcurl
>>
>> -          libcurl wrapper had some terrible memory leaks – this should be
>> fixed in 1.6
>>
>>
>>
>> This is true. Because the most used is default http transport.
>>
>> -          axis2c does not have support for proxy, ssl, etc with libcurl
>> transport – there are patches to do this though
>>
>>
>>
>> Again the reason is default is not curl. If you want curl, then you need
>> to do your homework.
>>
>>
>>
>> Samisa...
>>
>>
>>
>> From: Samisa Abeysinghe [mailto:samisa@wso2.com]
>> Sent: Thursday, March 04, 2010 9:29 AM
>>
>> To: Apache AXIS C User List
>>
>> Subject: Re: How to fix memory leak in Axis2/C client?
>>
>>
>>
>>
>>
>> On Thu, Mar 4, 2010 at 8:37 PM, Hatim Daginawala
>> <Ha...@argodata.com> wrote:
>>
>> You probably need to call axiom_node_free_tree on both request and
>> response node before reusing svc_client
>>
>>
>>
>> I do not think so - this will lead to seg faults if I recall right.
>>
>>
>>
>> If you cannot share the code, then the best is to use echo sample and see
>> if it leaks memory and if it does, report issues against that.
>>
>>
>>
>> It is like searching in the dark to talk about this without some concrete
>> code.
>>
>>
>>
>> Samisa...
>>
>>
>>
>>
>>
>> From: Olivier Mengué [mailto:omengue@oxymel.com]
>> Sent: Thursday, March 04, 2010 8:36 AM
>> To: Apache AXIS C User List; Apache AXIS C User List
>> Cc: Axis2/C user
>> Subject: RE : How to fix memory leak in Axis2/C client?
>>
>>
>>
>>
>>
>> Samisa Abeysinghe wrote:
>> >It is hard to tell from the list of methods given. Can you please provide
>> >the code you are using to test? Then we can profile and see where the
>> > leaks
>> >are.
>>
>> As you probably expected, no, I can't.
>>
>> Could you at least tell me if I have a good understanding of the API?
>> Is it my responsability to free the XML trees used in the SOAP exchange?
>>
>> Or if it may be a bug such as AXIS2C-1452?
>>
>> >> * for every call to the service:
>> >>     - I construct the XML request document:
>> >>         + axutil_qname_create()
>> >>         + axiom_element_create_with_qname()
>> >>         + axiom_element_create(), axiom_element_set_text()
>> >>     - axis2c_svc_client_send_receive()
>> >>     - I parse the XML response document:
>> >>         + axis2c_svc_client_get_http_status_code()
>> >>         + axis2c_svc_client_get_last_response_has_fault()
>> >>         + axiom_node_get_n,ext_sibling()
>> >>         + axiom_node_get_node_type()
>> >>         + axiom_node_get_data_element(), axiom_node_get_localname(),
>> >> axiom_node_get_namespace(), axiom_node_get_text()
>> >>
>> >>
>> >> I suspect that either the request XML tree and the response XML tree
>> >> are
>> >> not freed,
>> >> but I've seen nothing in the axis2c_svc_client API to do that.
>> >>
>> >> Which function calls are missing to fix my leak?
>> >>
>> >> Olivier.
>> >>
>>
>> Olivier Mengué
>> Oxymel, France.
>>
>> ________________________________
>>
>> ---------------------------------------------------
>> Confidentiality Notice: This electronic mail transmission is confidential,
>> may be privileged and should be read or retained only by the intended
>> recipient. If you have received this transmission in error, please
>> immediately notify the sender and delete it from your system.
>>
>>
>> --
>> Samisa Abeysinghe
>> Director, Engineering - WSO2 Inc.
>>
>> http://wso2.com/ - "lean . enterprise . middleware"
>>
>> ________________________________
>>
>> ---------------------------------------------------
>> Confidentiality Notice: This electronic mail transmission is confidential,
>> may be privileged and should be read or retained only by the intended
>> recipient. If you have received this transmission in error, please
>> immediately notify the sender and delete it from your system.
>>
>>
>> --
>> Samisa Abeysinghe
>> Director, Engineering - WSO2 Inc.
>>
>> http://wso2.com/ - "lean . enterprise . middleware"
>>
>> ________________________________
>> ---------------------------------------------------
>> Confidentiality Notice: This electronic mail transmission is confidential,
>> may be privileged and should be read or retained only by the intended
>> recipient. If you have received this transmission in error, please
>> immediately notify the sender and delete it from your system.
>
>
> --
> Samisa Abeysinghe
> Director, Engineering - WSO2 Inc.
>
> http://wso2.com/ - "lean . enterprise . middleware"
>



-- 
S.Uthaiyashankar
Software Architect
WSO2 Inc.
http://wso2.com/ - "lean . enterprise . middleware"

---------------------------------------------------------------------
To unsubscribe, e-mail: c-user-unsubscribe@axis.apache.org
For additional commands, e-mail: c-user-help@axis.apache.org


Re: How to fix memory leak in Axis2/C client?

Posted by Samisa Abeysinghe <sa...@wso2.com>.
On Fri, Mar 5, 2010 at 2:29 AM, Hatim Daginawala <
Hatim.Daginawala@argodata.com> wrote:

>  First of all let me say, I did not mean to offend anyone, undermine the
> work you do or even complain. If I did, I am sorry.
>
Sure, I was purely trying to make sure that other users do not misunderstand
anything.
And, of course if there are leaks, we got to fix them.

> Axis is great product and I am using axis2c in a production environment and
> I am very grateful. Thank you.
>
>
>
> The reason I say it’s not designed for reuse it precisely because it opens
> connection on every request. I had to switch to libcurl because I was
> running out of sockets.
>

We need to explore this more to find the problem.
One of the reasons that we wrote libcurl transport was to benefit from the
power of the library. We need to admit, transport libs is not our key
strength, rather SOAP engine aspects.
I think it has been some time since we put some effort to look into
improving libcurl support.

> When I  developed my code for 1.4, I did ran into various memory leaks and
> I did submit patches for it. However, I was able to work around most issues.
> 1.6 might not have those same issues.
>

We might want to revisit these in 1.7

Samisa...


>
>
> *From:* Samisa Abeysinghe [mailto:samisa@wso2.com]
> *Sent:* Thursday, March 04, 2010 11:16 AM
>
> *To:* Apache AXIS C User List
> *Subject:* Re: How to fix memory leak in Axis2/C client?
>
>
>
>
>
> On Thu, Mar 4, 2010 at 9:51 PM, Hatim Daginawala <
> Hatim.Daginawala@argodata.com> wrote:
>
> No harm in trying. I have been using release 1.5 for over a year now in a
> very high volume environment.
>
>
>
> svc_client is not designed to be reused.
>
>
>
> This is an incorrect statement. We reuse it, and it can be re-used.
>
>  Here are some of the issues I came across in 1.4/1.5
>
> -          It leaks all over the place - For example HTTP headers, you
> will have to reset all the headers after each use.
>
>
>
> I do not agree with this either. It does not leak all over the place. It
> sounds almost as if we have not done anything to fix leaks.
> This certainly is a misinterpretation and understatement.
>
>  -          Default HTTP transport opens socket for every request – you
> have to use libcurl
>
>   -          libcurl wrapper had some terrible memory leaks – this should
> be fixed in 1.6
>
>
>
> This is true. Because the most used is default http transport.
>
>  -          axis2c does not have support for proxy, ssl, etc with libcurl
> transport – there are patches to do this though
>
>
>
> Again the reason is default is not curl. If you want curl, then you need to
> do your homework.
>
>
>
> Samisa...
>
>
>
> *From:* Samisa Abeysinghe [mailto:samisa@wso2.com]
> *Sent:* Thursday, March 04, 2010 9:29 AM
>
>
> *To:* Apache AXIS C User List
>
> *Subject:* Re: How to fix memory leak in Axis2/C client?
>
>
>
>
>
> On Thu, Mar 4, 2010 at 8:37 PM, Hatim Daginawala <
> Hatim.Daginawala@argodata.com> wrote:
>
> You probably need to call axiom_node_free_tree on both request and response
> node before reusing svc_client
>
>
>
> I do not think so - this will lead to seg faults if I recall right.
>
>
>
> If you cannot share the code, then the best is to use echo sample and see
> if it leaks memory and if it does, report issues against that.
>
>
>
> It is like searching in the dark to talk about this without some concrete
> code.
>
>
>
> Samisa...
>
>
>
>
>
> *From:* Olivier Mengué [mailto:omengue@oxymel.com]
> *Sent:* Thursday, March 04, 2010 8:36 AM
> *To:* Apache AXIS C User List; Apache AXIS C User List
> *Cc:* Axis2/C user
> *Subject:* RE : How to fix memory leak in Axis2/C client?
>
>
>
>
>
> Samisa Abeysinghe wrote:
> >It is hard to tell from the list of methods given. Can you please provide
> >the code you are using to test? Then we can profile and see where the
> leaks
> >are.
>
> As you probably expected, no, I can't.
>
> Could you at least tell me if I have a good understanding of the API?
> Is it my responsability to free the XML trees used in the SOAP exchange?
>
> Or if it may be a bug such as AXIS2C-1452?
>
> >> * for every call to the service:
> >>     - I construct the XML request document:
> >>         + axutil_qname_create()
> >>         + axiom_element_create_with_qname()
> >>         + axiom_element_create(), axiom_element_set_text()
> >>     - axis2c_svc_client_send_receive()
> >>     - I parse the XML response document:
> >>         + axis2c_svc_client_get_http_status_code()
> >>         + axis2c_svc_client_get_last_response_has_fault()
> >>         + axiom_node_get_n,ext_sibling()
> >>         + axiom_node_get_node_type()
> >>         + axiom_node_get_data_element(), axiom_node_get_localname(),
> >> axiom_node_get_namespace(), axiom_node_get_text()
> >>
> >>
> >> I suspect that either the request XML tree and the response XML tree are
> >> not freed,
> >> but I've seen nothing in the axis2c_svc_client API to do that.
> >>
> >> Which function calls are missing to fix my leak?
> >>
> >> Olivier.
> >>
>
> Olivier Mengué
> Oxymel, France.
>    ------------------------------
>
> ---------------------------------------------------
> Confidentiality Notice: This electronic mail transmission is confidential,
> may be privileged and should be read or retained only by the intended
> recipient. If you have received this transmission in error, please
> immediately notify the sender and delete it from your system.
>
>
>
>
> --
> Samisa Abeysinghe
> Director, Engineering - WSO2 Inc.
>
> http://wso2.com/ - "lean . enterprise . middleware"
>     ------------------------------
>
> ---------------------------------------------------
> Confidentiality Notice: This electronic mail transmission is confidential,
> may be privileged and should be read or retained only by the intended
> recipient. If you have received this transmission in error, please
> immediately notify the sender and delete it from your system.
>
>
>
>
> --
> Samisa Abeysinghe
> Director, Engineering - WSO2 Inc.
>
> http://wso2.com/ - "lean . enterprise . middleware"
>
> ------------------------------
> ---------------------------------------------------
> Confidentiality Notice: This electronic mail transmission is confidential,
> may be privileged and should be read or retained only by the intended
> recipient. If you have received this transmission in error, please
> immediately notify the sender and delete it from your system.
>
>


-- 
Samisa Abeysinghe
Director, Engineering - WSO2 Inc.

http://wso2.com/ - "lean . enterprise . middleware"

RE: How to fix memory leak in Axis2/C client?

Posted by Hatim Daginawala <Ha...@argodata.com>.
First of all let me say, I did not mean to offend anyone, undermine the work you do or even complain. If I did, I am sorry.

Axis is great product and I am using axis2c in a production environment and I am very grateful. Thank you.

 

The reason I say it's not designed for reuse it precisely because it opens connection on every request. I had to switch to libcurl because I was running out of sockets.

When I  developed my code for 1.4, I did ran into various memory leaks and I did submit patches for it. However, I was able to work around most issues. 1.6 might not have those same issues.

 

From: Samisa Abeysinghe [mailto:samisa@wso2.com] 
Sent: Thursday, March 04, 2010 11:16 AM
To: Apache AXIS C User List
Subject: Re: How to fix memory leak in Axis2/C client?

 

 

On Thu, Mar 4, 2010 at 9:51 PM, Hatim Daginawala <Ha...@argodata.com> wrote:

No harm in trying. I have been using release 1.5 for over a year now in a very high volume environment.

 

svc_client is not designed to be reused. 

 

This is an incorrect statement. We reuse it, and it can be re-used.  

	Here are some of the issues I came across in 1.4/1.5

	-          It leaks all over the place - For example HTTP headers, you will have to reset all the headers after each use.

 

I do not agree with this either. It does not leak all over the place. It sounds almost as if we have not done anything to fix leaks. This certainly is a misinterpretation and understatement. 

	-          Default HTTP transport opens socket for every request - you have to use libcurl 

	-          libcurl wrapper had some terrible memory leaks - this should be fixed in 1.6

 

This is true. Because the most used is default http transport.  

	-          axis2c does not have support for proxy, ssl, etc with libcurl transport - there are patches to do this though

 

Again the reason is default is not curl. If you want curl, then you need to do your homework. 

 

Samisa...

	 

	From: Samisa Abeysinghe [mailto:samisa@wso2.com] 
	Sent: Thursday, March 04, 2010 9:29 AM

	
	To: Apache AXIS C User List

	Subject: Re: How to fix memory leak in Axis2/C client?

	 

	 

	On Thu, Mar 4, 2010 at 8:37 PM, Hatim Daginawala <Ha...@argodata.com> wrote:

	You probably need to call axiom_node_free_tree on both request and response node before reusing svc_client

	 

	I do not think so - this will lead to seg faults if I recall right.

	 

	If you cannot share the code, then the best is to use echo sample and see if it leaks memory and if it does, report issues against that. 

	 

	It is like searching in the dark to talk about this without some concrete code. 

	 

	Samisa...

	 

		 

		From: Olivier Mengué [mailto:omengue@oxymel.com] 
		Sent: Thursday, March 04, 2010 8:36 AM
		To: Apache AXIS C User List; Apache AXIS C User List
		Cc: Axis2/C user
		Subject: RE : How to fix memory leak in Axis2/C client?

		 

		 

		Samisa Abeysinghe wrote:
		>It is hard to tell from the list of methods given. Can you please provide
		>the code you are using to test? Then we can profile and see where the leaks
		>are.
		
		As you probably expected, no, I can't.
		
		Could you at least tell me if I have a good understanding of the API?
		Is it my responsability to free the XML trees used in the SOAP exchange?
		
		Or if it may be a bug such as AXIS2C-1452?
		
		>> * for every call to the service:
		>>     - I construct the XML request document:
		>>         + axutil_qname_create()
		>>         + axiom_element_create_with_qname()
		>>         + axiom_element_create(), axiom_element_set_text()
		>>     - axis2c_svc_client_send_receive()
		>>     - I parse the XML response document:
		>>         + axis2c_svc_client_get_http_status_code()
		>>         + axis2c_svc_client_get_last_response_has_fault()
		>>         + axiom_node_get_n,ext_sibling()
		>>         + axiom_node_get_node_type()
		>>         + axiom_node_get_data_element(), axiom_node_get_localname(),
		>> axiom_node_get_namespace(), axiom_node_get_text()
		>>
		>>
		>> I suspect that either the request XML tree and the response XML tree are
		>> not freed,
		>> but I've seen nothing in the axis2c_svc_client API to do that.
		>>
		>> Which function calls are missing to fix my leak?
		>>
		>> Olivier.
		>>
		
		Olivier Mengué
		Oxymel, France. 

________________________________

		---------------------------------------------------
		Confidentiality Notice: This electronic mail transmission is confidential, 
		may be privileged and should be read or retained only by the intended
		recipient. If you have received this transmission in error, please
		immediately notify the sender and delete it from your system. 

	
	
	
	-- 
	Samisa Abeysinghe 
	Director, Engineering - WSO2 Inc.
	
	http://wso2.com/ - "lean . enterprise . middleware"

________________________________

	---------------------------------------------------
	Confidentiality Notice: This electronic mail transmission is confidential, 
	may be privileged and should be read or retained only by the intended
	recipient. If you have received this transmission in error, please
	immediately notify the sender and delete it from your system. 




-- 
Samisa Abeysinghe 
Director, Engineering - WSO2 Inc.

http://wso2.com/ - "lean . enterprise . middleware"



---------------------------------------------------
Confidentiality Notice:  This electronic mail transmission is confidential, 
may be privileged and should be read or retained only by the intended
recipient.  If you have received this transmission in error, please
immediately notify the sender and delete it from your system.

Re: How to fix memory leak in Axis2/C client?

Posted by Ash VI <as...@gmail.com>.
Hi All,

I have seen the same memory leak problem in my client code implementation.
Though like to know if any workaround and temporary solution for this
instead of waiting 7.0 version.

I am using axis2/c 6.0 with libxml2 parser. I created stub using wsld2c for
JBoss WS and it uses SSL. My application runs fine, but memory grows
on multiple webservice call. I put debugger and perfmon/task manger  to
observe this and clearly seen taht memory is not get released when
application request and response freed.

I see the memory get released whenever application frees the stub/env object
only (axis2_stub_free,axutil_env_free), not when request and response object
freed by using stub created functions (adb_XXXXX_free,
adb_XXXXXResponse_free).

I got blocked as my application needs multiple webservice calls and in
multithreaded environement.

The following solution I can think -
1) Create stub and env object for every web service call or thread and free
it immediately to avoid memory leak. Though this workaround leads problem
(access voilation) in when I use it in multithreaded environment

Ex: thread 1,  creates stub and env , invokes the webservice call and frees
the stub and env object. After that when I create other object whenever
required in other thread and it gives the access violation in
axis2_stub_create_MYWebService(..) at
axis2_stub_create_with_endpoint_ref_and_client_home(...) while creating the
stub. Also sometime, application creates stub object in callback function
(main thread)  which is called from another thread fuction using callback
handler and the same issue is observed.

Note that I have used axis2_options_set_xml_parser_reset() function by
suspecting libxml2 problem, but it did not help me. I have gone through
following posts, but could not resolve memory leak with multilthreaded
application.


Let know if we have any workaround to to resolve this . Any help/pointers
will be greatly appreciated.


Thanks,
Ashok

----
Releated Posts:-

Memory maangement in generated ad...
http://markmail.org/message/mqn4lsloubayyr3k#query:axis-c%20stub%20adb%20not%20freeing%20memory+page:1+mid:qsplc6qeyuggheen+state:results

Multithreading
http://marc.info/?l=axis-c-dev&m=122899239530621&w=2
Multithreaded Again
http://marc.info/?l=axis-c-user&m=118399660218878&w=2
Seg fault in libxml when svc client torn down in a multithreaded client
https://issues.apache.org/jira/browse/AXIS2C-884


 Stack Trace for access violation in multilthreaded application (Release
build):
 ----------------------------------------------------------------------------------------------------

axis2_stub_create_MYWebService(..)
<-->axis2_stub_create_with_endpoint_ref_and_client_home(...)
 ntdll.dll!7c91b21a()
  [Frames below may be incorrect and/or missing, no symbols loaded for
ntdll.dll]
  ntdll.dll!7c9101db()
  msvcrt.dll!77c2c3c9()
  msvcrt.dll!77c2c3ce()
  msvcrt.dll!77c2c3ce()
  msvcrt.dll!77c2c3e7()
  ntdll.dll!7c901046()
  libxml2.dll!0143dc6d()
  libxml2.dll!014024c4()
  libxml2.dll!01456115()
  libxml2.dll!01459720()
  libxml2.dll!0145b87b()
  axis2_engine.dll!1001cd82()
  axis2_engine.dll!10047821()
  axis2_engine.dll!1004c02b()
  axis2_engine.dll!10049fa5()
  axis2_engine.dll!10049faf()
  axis2_engine.dll!10061eb7()
  axis2_engine.dll!10053681()
  axis2_engine.dll!10053b25()
> DaaSAgent.exe!axis2_stub_create_MyWebService(const axutil_env *
env=0x02198270, const char * client_home=0x01dec9d0, const char *
endpoint_uri=0x01def660)  Line 36 + 0x14 bytes C
  DaaSAgent.exe!AxisClientStub::AxisClientStub(const char *
endpointUri=0x01def660, const char * clienthome=0x01dec9d0, const char *
logfile=0x0115ff00)  Line 48 + 0x14 bytes C++




Thanks,
Ashok

On Wed, Mar 10, 2010 at 10:43 PM, George Sherwood <gs...@att.net> wrote:

>  Olivier,
> There is a 1.6.0 service using https described at
> http://testcover.com/pub/wsdl_notes.php
> If this is simple enough to meet your need, let me know, and I'll send you
> an activation code so that you can use it.
> George Sherwood
> Testcover.com, LLC
>
>  ----- Original Message -----
> *From:* Olivier Mengué <om...@oxymel.com>
>  *To:* Apache AXIS C User List <c-...@axis.apache.org> ; Apache AXIS C
> User List <c-...@axis.apache.org>
>  *Sent:* Wednesday, March 10, 2010 11:46 AM
> *Subject:* RE : How to fix memory leak in Axis2/C client?
>
>
>
>
> Samisa Abeysinghe wrote:
>
> >>On Thu, Mar 4, 2010 at 9:51 PM, Hatim Daginawala wrote:
> >>
> >> svc_client is not designed to be reused.
> >>
>
> > This is an incorrect statement. We reuse it, and it can be re-used.
>
> I have not been able to reproduce the leak with a simple HTTP client that
> queries the Mellbourn.com password generator service.
> http://www.service-repository.com/service/wsdl?id=98309
>
> However I have the leak in my HTTPs client. So I suppose that Axis2/C leaks
> OpenSSL objects.
> That's also what Insure++ told me, but I've not been able to to distinguish
> false positive from true ones.
>
> If someone knows a public webservice that has an HTTPs interface with
> simple message I would be glad to provide an Axis2/C test program.
>
> Olivier.
>
>

Re: How to fix memory leak in Axis2/C client?

Posted by George Sherwood <gs...@att.net>.
RE : How to fix memory leak in Axis2/C client?Olivier,
There is a 1.6.0 service using https described at http://testcover.com/pub/wsdl_notes.php 
If this is simple enough to meet your need, let me know, and I'll send you an activation code so that you can use it.
George Sherwood
Testcover.com, LLC
  ----- Original Message ----- 
  From: Olivier Mengué 
  To: Apache AXIS C User List ; Apache AXIS C User List 
  Sent: Wednesday, March 10, 2010 11:46 AM
  Subject: RE : How to fix memory leak in Axis2/C client?






  Samisa Abeysinghe wrote:
  >>On Thu, Mar 4, 2010 at 9:51 PM, Hatim Daginawala wrote:
  >>
  >> svc_client is not designed to be reused.
  >>

  > This is an incorrect statement. We reuse it, and it can be re-used.

  I have not been able to reproduce the leak with a simple HTTP client that queries the Mellbourn.com password generator service.
  http://www.service-repository.com/service/wsdl?id=98309

  However I have the leak in my HTTPs client. So I suppose that Axis2/C leaks OpenSSL objects.
  That's also what Insure++ told me, but I've not been able to to distinguish false positive from true ones.

  If someone knows a public webservice that has an HTTPs interface with simple message I would be glad to provide an Axis2/C test program.

  Olivier. 

RE : How to fix memory leak in Axis2/C client?

Posted by Olivier Mengué <om...@oxymel.com>.


Samisa Abeysinghe wrote:
>>On Thu, Mar 4, 2010 at 9:51 PM, Hatim Daginawala wrote:
>>
>> svc_client is not designed to be reused.
>>

> This is an incorrect statement. We reuse it, and it can be re-used.

I have not been able to reproduce the leak with a simple HTTP client that queries the Mellbourn.com password generator service.
http://www.service-repository.com/service/wsdl?id=98309

However I have the leak in my HTTPs client. So I suppose that Axis2/C leaks OpenSSL objects.
That's also what Insure++ told me, but I've not been able to to distinguish false positive from true ones.

If someone knows a public webservice that has an HTTPs interface with simple message I would be glad to provide an Axis2/C test program.

Olivier.

Re: How to fix memory leak in Axis2/C client?

Posted by Samisa Abeysinghe <sa...@wso2.com>.
On Thu, Mar 4, 2010 at 9:51 PM, Hatim Daginawala <
Hatim.Daginawala@argodata.com> wrote:

>  No harm in trying. I have been using release 1.5 for over a year now in a
> very high volume environment.
>
>
>
> svc_client is not designed to be reused.
>

This is an incorrect statement. We reuse it, and it can be re-used.

> Here are some of the issues I came across in 1.4/1.5
>
> -          It leaks all over the place - For example HTTP headers, you
> will have to reset all the headers after each use.
>

I do not agree with this either. It does not leak all over the place. It
sounds almost as if we have not done anything to fix leaks.
This certainly is a misinterpretation and understatement.

> -          Default HTTP transport opens socket for every request – you
> have to use libcurl
>
-          libcurl wrapper had some terrible memory leaks – this should be
> fixed in 1.6
>

This is true. Because the most used is default http transport.

> -          axis2c does not have support for proxy, ssl, etc with libcurl
> transport – there are patches to do this though
>

Again the reason is default is not curl. If you want curl, then you need to
do your homework.

Samisa...

>
>
> *From:* Samisa Abeysinghe [mailto:samisa@wso2.com]
> *Sent:* Thursday, March 04, 2010 9:29 AM
>
> *To:* Apache AXIS C User List
> *Subject:* Re: How to fix memory leak in Axis2/C client?
>
>
>
>
>
> On Thu, Mar 4, 2010 at 8:37 PM, Hatim Daginawala <
> Hatim.Daginawala@argodata.com> wrote:
>
> You probably need to call axiom_node_free_tree on both request and response
> node before reusing svc_client
>
>
>
> I do not think so - this will lead to seg faults if I recall right.
>
>
>
> If you cannot share the code, then the best is to use echo sample and see
> if it leaks memory and if it does, report issues against that.
>
>
>
> It is like searching in the dark to talk about this without some concrete
> code.
>
>
>
> Samisa...
>
>
>
>
>
> *From:* Olivier Mengué [mailto:omengue@oxymel.com]
> *Sent:* Thursday, March 04, 2010 8:36 AM
> *To:* Apache AXIS C User List; Apache AXIS C User List
> *Cc:* Axis2/C user
> *Subject:* RE : How to fix memory leak in Axis2/C client?
>
>
>
>
>
> Samisa Abeysinghe wrote:
> >It is hard to tell from the list of methods given. Can you please provide
> >the code you are using to test? Then we can profile and see where the
> leaks
> >are.
>
> As you probably expected, no, I can't.
>
> Could you at least tell me if I have a good understanding of the API?
> Is it my responsability to free the XML trees used in the SOAP exchange?
>
> Or if it may be a bug such as AXIS2C-1452?
>
> >> * for every call to the service:
> >>     - I construct the XML request document:
> >>         + axutil_qname_create()
> >>         + axiom_element_create_with_qname()
> >>         + axiom_element_create(), axiom_element_set_text()
> >>     - axis2c_svc_client_send_receive()
> >>     - I parse the XML response document:
> >>         + axis2c_svc_client_get_http_status_code()
> >>         + axis2c_svc_client_get_last_response_has_fault()
> >>         + axiom_node_get_n,ext_sibling()
> >>         + axiom_node_get_node_type()
> >>         + axiom_node_get_data_element(), axiom_node_get_localname(),
> >> axiom_node_get_namespace(), axiom_node_get_text()
> >>
> >>
> >> I suspect that either the request XML tree and the response XML tree are
> >> not freed,
> >> but I've seen nothing in the axis2c_svc_client API to do that.
> >>
> >> Which function calls are missing to fix my leak?
> >>
> >> Olivier.
> >>
>
> Olivier Mengué
> Oxymel, France.
>    ------------------------------
>
> ---------------------------------------------------
> Confidentiality Notice: This electronic mail transmission is confidential,
> may be privileged and should be read or retained only by the intended
> recipient. If you have received this transmission in error, please
> immediately notify the sender and delete it from your system.
>
>
>
>
> --
> Samisa Abeysinghe
> Director, Engineering - WSO2 Inc.
>
> http://wso2.com/ - "lean . enterprise . middleware"
>
> ------------------------------
> ---------------------------------------------------
> Confidentiality Notice: This electronic mail transmission is confidential,
> may be privileged and should be read or retained only by the intended
> recipient. If you have received this transmission in error, please
> immediately notify the sender and delete it from your system.
>
>


-- 
Samisa Abeysinghe
Director, Engineering - WSO2 Inc.

http://wso2.com/ - "lean . enterprise . middleware"

RE: How to fix memory leak in Axis2/C client?

Posted by Hatim Daginawala <Ha...@argodata.com>.
No harm in trying. I have been using release 1.5 for over a year now in a very high volume environment.

 

svc_client is not designed to be reused. Here are some of the issues I came across in 1.4/1.5

-          It leaks all over the place - For example HTTP headers, you will have to reset all the headers after each use.

-          Default HTTP transport opens socket for every request - you have to use libcurl

-          libcurl wrapper had some terrible memory leaks - this should be fixed in 1.6

-          axis2c does not have support for proxy, ssl, etc with libcurl transport - there are patches to do this though

 

From: Samisa Abeysinghe [mailto:samisa@wso2.com] 
Sent: Thursday, March 04, 2010 9:29 AM
To: Apache AXIS C User List
Subject: Re: How to fix memory leak in Axis2/C client?

 

 

On Thu, Mar 4, 2010 at 8:37 PM, Hatim Daginawala <Ha...@argodata.com> wrote:

You probably need to call axiom_node_free_tree on both request and response node before reusing svc_client

 

I do not think so - this will lead to seg faults if I recall right.

 

If you cannot share the code, then the best is to use echo sample and see if it leaks memory and if it does, report issues against that. 

 

It is like searching in the dark to talk about this without some concrete code. 

 

Samisa...

 

	 

	From: Olivier Mengué [mailto:omengue@oxymel.com] 
	Sent: Thursday, March 04, 2010 8:36 AM
	To: Apache AXIS C User List; Apache AXIS C User List
	Cc: Axis2/C user
	Subject: RE : How to fix memory leak in Axis2/C client?

	 

	 

	Samisa Abeysinghe wrote:
	>It is hard to tell from the list of methods given. Can you please provide
	>the code you are using to test? Then we can profile and see where the leaks
	>are.
	
	As you probably expected, no, I can't.
	
	Could you at least tell me if I have a good understanding of the API?
	Is it my responsability to free the XML trees used in the SOAP exchange?
	
	Or if it may be a bug such as AXIS2C-1452?
	
	>> * for every call to the service:
	>>     - I construct the XML request document:
	>>         + axutil_qname_create()
	>>         + axiom_element_create_with_qname()
	>>         + axiom_element_create(), axiom_element_set_text()
	>>     - axis2c_svc_client_send_receive()
	>>     - I parse the XML response document:
	>>         + axis2c_svc_client_get_http_status_code()
	>>         + axis2c_svc_client_get_last_response_has_fault()
	>>         + axiom_node_get_n,ext_sibling()
	>>         + axiom_node_get_node_type()
	>>         + axiom_node_get_data_element(), axiom_node_get_localname(),
	>> axiom_node_get_namespace(), axiom_node_get_text()
	>>
	>>
	>> I suspect that either the request XML tree and the response XML tree are
	>> not freed,
	>> but I've seen nothing in the axis2c_svc_client API to do that.
	>>
	>> Which function calls are missing to fix my leak?
	>>
	>> Olivier.
	>>
	
	Olivier Mengué
	Oxymel, France. 

________________________________

	---------------------------------------------------
	Confidentiality Notice: This electronic mail transmission is confidential, 
	may be privileged and should be read or retained only by the intended
	recipient. If you have received this transmission in error, please
	immediately notify the sender and delete it from your system. 




-- 
Samisa Abeysinghe 
Director, Engineering - WSO2 Inc.

http://wso2.com/ - "lean . enterprise . middleware"



---------------------------------------------------
Confidentiality Notice:  This electronic mail transmission is confidential, 
may be privileged and should be read or retained only by the intended
recipient.  If you have received this transmission in error, please
immediately notify the sender and delete it from your system.

Re: How to fix memory leak in Axis2/C client?

Posted by Samisa Abeysinghe <sa...@wso2.com>.
On Thu, Mar 4, 2010 at 8:37 PM, Hatim Daginawala <
Hatim.Daginawala@argodata.com> wrote:

>  You probably need to call axiom_node_free_tree on both request and
> response node before reusing svc_client
>

I do not think so - this will lead to seg faults if I recall right.

If you cannot share the code, then the best is to use echo sample and see if
it leaks memory and if it does, report issues against that.

It is like searching in the dark to talk about this without some concrete
code.

Samisa...


>
>
> *From:* Olivier Mengué [mailto:omengue@oxymel.com]
> *Sent:* Thursday, March 04, 2010 8:36 AM
> *To:* Apache AXIS C User List; Apache AXIS C User List
> *Cc:* Axis2/C user
> *Subject:* RE : How to fix memory leak in Axis2/C client?
>
>
>
>
>
> Samisa Abeysinghe wrote:
> >It is hard to tell from the list of methods given. Can you please provide
> >the code you are using to test? Then we can profile and see where the
> leaks
> >are.
>
> As you probably expected, no, I can't.
>
> Could you at least tell me if I have a good understanding of the API?
> Is it my responsability to free the XML trees used in the SOAP exchange?
>
> Or if it may be a bug such as AXIS2C-1452?
>
> >> * for every call to the service:
> >>     - I construct the XML request document:
> >>         + axutil_qname_create()
> >>         + axiom_element_create_with_qname()
> >>         + axiom_element_create(), axiom_element_set_text()
> >>     - axis2c_svc_client_send_receive()
> >>     - I parse the XML response document:
> >>         + axis2c_svc_client_get_http_status_code()
> >>         + axis2c_svc_client_get_last_response_has_fault()
> >>         + axiom_node_get_n,ext_sibling()
> >>         + axiom_node_get_node_type()
> >>         + axiom_node_get_data_element(), axiom_node_get_localname(),
> >> axiom_node_get_namespace(), axiom_node_get_text()
> >>
> >>
> >> I suspect that either the request XML tree and the response XML tree are
> >> not freed,
> >> but I've seen nothing in the axis2c_svc_client API to do that.
> >>
> >> Which function calls are missing to fix my leak?
> >>
> >> Olivier.
> >>
>
> Olivier Mengué
> Oxymel, France.
>
> ------------------------------
> ---------------------------------------------------
> Confidentiality Notice: This electronic mail transmission is confidential,
> may be privileged and should be read or retained only by the intended
> recipient. If you have received this transmission in error, please
> immediately notify the sender and delete it from your system.
>
>


-- 
Samisa Abeysinghe
Director, Engineering - WSO2 Inc.

http://wso2.com/ - "lean . enterprise . middleware"

RE: How to fix memory leak in Axis2/C client?

Posted by Hatim Daginawala <Ha...@argodata.com>.
You probably need to call axiom_node_free_tree on both request and response node before reusing svc_client

 

From: Olivier Mengué [mailto:omengue@oxymel.com] 
Sent: Thursday, March 04, 2010 8:36 AM
To: Apache AXIS C User List; Apache AXIS C User List
Cc: Axis2/C user
Subject: RE : How to fix memory leak in Axis2/C client?

 

 

Samisa Abeysinghe wrote:
>It is hard to tell from the list of methods given. Can you please provide
>the code you are using to test? Then we can profile and see where the leaks
>are.

As you probably expected, no, I can't.

Could you at least tell me if I have a good understanding of the API?
Is it my responsability to free the XML trees used in the SOAP exchange?

Or if it may be a bug such as AXIS2C-1452?

>> * for every call to the service:
>>     - I construct the XML request document:
>>         + axutil_qname_create()
>>         + axiom_element_create_with_qname()
>>         + axiom_element_create(), axiom_element_set_text()
>>     - axis2c_svc_client_send_receive()
>>     - I parse the XML response document:
>>         + axis2c_svc_client_get_http_status_code()
>>         + axis2c_svc_client_get_last_response_has_fault()
>>         + axiom_node_get_n,ext_sibling()
>>         + axiom_node_get_node_type()
>>         + axiom_node_get_data_element(), axiom_node_get_localname(),
>> axiom_node_get_namespace(), axiom_node_get_text()
>>
>>
>> I suspect that either the request XML tree and the response XML tree are
>> not freed,
>> but I've seen nothing in the axis2c_svc_client API to do that.
>>
>> Which function calls are missing to fix my leak?
>>
>> Olivier.
>>

Olivier Mengué
Oxymel, France. 



---------------------------------------------------
Confidentiality Notice:  This electronic mail transmission is confidential, 
may be privileged and should be read or retained only by the intended
recipient.  If you have received this transmission in error, please
immediately notify the sender and delete it from your system.