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 Rui Feng Guan <gu...@gmail.com> on 2008/04/08 16:28:43 UTC

a question about memory free

I am a beginner in axis2.
In sample source code notify_client.c, axiom_element_create creates a node
notify_om_node. But after the node is created, there is no place to free
this node. I can only find two places to free memory: axis2_svc_client_free
and axutil_env_free. But after reading source code of these two functions,
no one free the node created by function axiom_element_create. Did I miss
something or the sample forget to free the node? If it is, how to free the
node? Thanks

Re: a question about memory free

Posted by Rui Feng Guan <gu...@gmail.com>.
Thanks very much.

On Tue, Apr 8, 2008 at 2:36 PM, Manjula Peiris <ma...@wso2.com> wrote:

> Hi Rui,
>
> You can find some important related information from here [1]
>
> [1] http://wso2.org/library/3412
>
> Thanks,
> -Manjula
>
> On Tue, 2008-04-08 at 23:53 +0800, Rui Feng Guan wrote:
> > Thanks for your answer very much! Yes, it seems that the axis2/C
> > manual is not as good as I expected.
> >
> > I have another question:
> >
> > My code is as following. I created nodes 10 times and in each time, I
> > send them to server. I did not free any memory in the while loop but
> > only free svc_client once. Do I free all nodes?
> > Will the code lead to memory leak?
> >
> > main()
> > {
> > ..........
> > int i = 0;
> > while(i++ < 10)
> > {
> >         payload = build_om_request(env, "abc");
> >         ret_node = axis2_svc_client_send_receive(svc_client, env,
> > payload);
> > }
> >
> > if (svc_client)
> > {
> >         axis2_svc_client_free(svc_client, env);
> >         svc_client = NULL;
> > }
> > .............
> > }
> >
> > axiom_node_t *
> > build_om_request(const axutil_env_t *env, char *request)
> > {
> >     axiom_node_t* greet_om_node = NULL;
> >     axiom_element_t * greet_om_ele = NULL;
> >     greet_om_ele = axiom_element_create(env, NULL, "greet", NULL,
> > &greet_om_node);
> >     axiom_element_set_text(greet_om_ele, env, request, greet_om_node);
> >
> >     return greet_om_node;
> >
> > }
> >
> >
> > On 4/8/08, Samisa Abeysinghe <sa...@wso2.com> wrote:
> >         Rui Feng Guan wrote:
> >                 I am a beginner in axis2.
> >                 In sample source code notify_client.c,
> >                 axiom_element_create creates a node notify_om_node.
> >                 But after the node is created, there is no place to
> >                 free this node. I can only find two places to free
> >                 memory: axis2_svc_client_free and axutil_env_free. But
> >                 after reading source code of these two functions, no
> >                 one free the node created by function
> >                 axiom_element_create. Did I miss something or the
> >                 sample forget to free the node? If it is, how to free
> >                 the node?
> >
> >         I think we should document this somewhere. Anyway, once you
> >         pass the payload to service client operation invocation, it
> >         takes over the node ownership and frees it when service client
> >         is freed.
> >
> >         Thanks,
> >         Samisa...
> >
> >
> >
> ---------------------------------------------------------------------
> >         To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> >         For additional commands, e-mail:
> >         axis-c-user-help@ws.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
>
>

Re: a question about memory free

Posted by Manjula Peiris <ma...@wso2.com>.
Hi Rui,

You can find some important related information from here [1]

[1] http://wso2.org/library/3412

Thanks,
-Manjula

On Tue, 2008-04-08 at 23:53 +0800, Rui Feng Guan wrote:
> Thanks for your answer very much! Yes, it seems that the axis2/C
> manual is not as good as I expected.
>  
> I have another question:
>  
> My code is as following. I created nodes 10 times and in each time, I
> send them to server. I did not free any memory in the while loop but
> only free svc_client once. Do I free all nodes?
> Will the code lead to memory leak?
>  
> main()
> {
> ..........
> int i = 0;
> while(i++ < 10)
> {
>         payload = build_om_request(env, "abc");
>         ret_node = axis2_svc_client_send_receive(svc_client, env,
> payload);
> }
>  
> if (svc_client)
> {
>         axis2_svc_client_free(svc_client, env);
>         svc_client = NULL;
> }
> .............
> }
>  
> axiom_node_t *
> build_om_request(const axutil_env_t *env, char *request)
> {
>     axiom_node_t* greet_om_node = NULL;
>     axiom_element_t * greet_om_ele = NULL;
>     greet_om_ele = axiom_element_create(env, NULL, "greet", NULL,
> &greet_om_node);
>     axiom_element_set_text(greet_om_ele, env, request, greet_om_node);
> 
>     return greet_om_node;
> 
> }
> 
> 
> On 4/8/08, Samisa Abeysinghe <sa...@wso2.com> wrote: 
>         Rui Feng Guan wrote:
>                 I am a beginner in axis2.
>                 In sample source code notify_client.c,
>                 axiom_element_create creates a node notify_om_node.
>                 But after the node is created, there is no place to
>                 free this node. I can only find two places to free
>                 memory: axis2_svc_client_free and axutil_env_free. But
>                 after reading source code of these two functions, no
>                 one free the node created by function
>                 axiom_element_create. Did I miss something or the
>                 sample forget to free the node? If it is, how to free
>                 the node?
>         
>         I think we should document this somewhere. Anyway, once you
>         pass the payload to service client operation invocation, it
>         takes over the node ownership and frees it when service client
>         is freed.
>         
>         Thanks,
>         Samisa...
>         
>         
>         ---------------------------------------------------------------------
>         To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
>         For additional commands, e-mail:
>         axis-c-user-help@ws.apache.org
>         
> 


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


Re: a question about memory free

Posted by Samisa Abeysinghe <sa...@wso2.com>.
Rui Feng Guan wrote:
> Thanks for your answer very much! Yes, it seems that the axis2/C 
> manual is not as good as I expected.

Help improve it :)

>  
> I have another question:
>  
> My code is as following. I created nodes 10 times and in each time, I 
> send them to server. I did not free any memory in the while loop but 
> only free svc_client once. Do I free all nodes?
> Will the code lead to memory leak?

No.

Samisa...


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


Re: a question about memory free

Posted by Rui Feng Guan <gu...@gmail.com>.
Thanks for your answer very much! Yes, it seems that the axis2/C manual is
not as good as I expected.

I have another question:

My code is as following. I created nodes 10 times and in each time, I send
them to server. I did not free any memory in the while loop but only free
svc_client once. Do I free all nodes?
Will the code lead to memory leak?

main()
{
..........
int i = 0;
while(i++ < 10)
{
        payload = build_om_request(env, "abc");
        ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
}

if (svc_client)
{
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
}
.............
}

axiom_node_t *
build_om_request(const axutil_env_t *env, char *request)
{
    axiom_node_t* greet_om_node = NULL;
    axiom_element_t * greet_om_ele = NULL;

    greet_om_ele = axiom_element_create(env, NULL, "greet", NULL,
&greet_om_node);
    axiom_element_set_text(greet_om_ele, env, request, greet_om_node);

    return greet_om_node;

}
On 4/8/08, Samisa Abeysinghe <sa...@wso2.com> wrote:
>
> Rui Feng Guan wrote:
>
> > I am a beginner in axis2.
> > In sample source code notify_client.c, axiom_element_create creates a
> > node notify_om_node. But after the node is created, there is no place to
> > free this node. I can only find two places to free memory:
> > axis2_svc_client_free and axutil_env_free. But after reading source code of
> > these two functions, no one free the node created by function
> > axiom_element_create. Did I miss something or the sample forget to free the
> > node? If it is, how to free the node?
> >
>
> I think we should document this somewhere. Anyway, once you pass the
> payload to service client operation invocation, it takes over the node
> ownership and frees it when service client is freed.
>
> Thanks,
> Samisa...
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
>
>

Re: a question about memory free

Posted by Samisa Abeysinghe <sa...@wso2.com>.
Rui Feng Guan wrote:
> I am a beginner in axis2.
> In sample source code notify_client.c, axiom_element_create creates a 
> node notify_om_node. But after the node is created, there is no place 
> to free this node. I can only find two places to free memory: 
> axis2_svc_client_free and axutil_env_free. But after reading source 
> code of these two functions, no one free the node created by function 
> axiom_element_create. Did I miss something or the sample forget to 
> free the node? If it is, how to free the node?

I think we should document this somewhere. Anyway, once you pass the 
payload to service client operation invocation, it takes over the node 
ownership and frees it when service client is freed.

Thanks,
Samisa...


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