axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manjula Peiris <>
Subject Re: Memory management in Axis2/C
Date Mon, 20 Aug 2007 05:41:53 GMT
Hi Subra,

Please see my comments inline.

On Sun, 2007-08-19 at 20:11 -0400, Subra A Narayanan wrote:
> Hello everyone,
> I had some very basic questions about memory management in Axis2/C and
> hope I can clarify my doubts with your help. I did go through the
> article on memory management => but still
> have some questions.
> 1. I am working on a new webservice for which I just copied the 'math'
> service from the samples and have been just modifying it. In the 'add'
> operation of the 'math' service, there are some calls to
> axiom_element_get_text function which returns a const axis2_char_t* to
> retrieve the parameters from the soap xml document. Who is responsible
> for freeing up this memory? I assume since its const pointer and I
> didnt explicitly allocate memory, it will be clened up by the
> framework. But when does this happen? I looked at the math_free
> function in math_skeleton.c file but it doesn't tell me much. Is this
> when the clean up happens?
> int AXIS2_CALL
> math_free(axis2_svc_skeleton_t *svc_skeleton,
>         const axutil_env_t *env)
> {
>     if (svc_skeleton)
>     {
>         AXIS2_FREE(env->allocator, svc_skeleton);
>         svc_skeleton = NULL;
>     }
>     return AXIS2_SUCCESS;
> }
Those will be freed from the framework when the corresponding om_tree is
freed for the soap xml document. But if you duplicate the text value
using axutil_strdup you need to free it by your own.

> 2. Is there any advantage in using the AXIS2_MALLOC over jus malloc?
> From my understanding, AXIS2_MALLOC just hides the env specific
> implementation of memory allocation. So if I am using 'C' either
> malloc or AXIS2_MALLOC are one and the same. Am I correct? On a
> similar note, is there any advantage in using axis2_char_t* over just
> char*? 
Yes there are advantages.  when using AXIS2_MALLOC you can plug
different mempry allocation mechanisms to Axis2/C. For example when
Axis2/C is used with Apache2 (httpd module) it uses httpd memory pools.
If you use malloc you can't get these advantages.

Using axis2_char also has the same advantage. You can plug different
charactor encoding systems using axis2_char.


> I thank all of you for ur help and patience as I try to understand the
> Axis2 framework.
> Subra

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message