axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dimuthu Gamage" <dimut...@gmail.com>
Subject Re: memory maangement in generated adb client stub
Date Wed, 23 Jan 2008 12:59:01 GMT
Hi martin,

If you are using adb in client side you have to explicitly free the
allocated adb object for (only) the request and response. That is call
adb_EventPerformedResponse_free and adb_EventPerformed_free at the
end.

Seems you are using the nightly build
(http://people.apache.org/dist/axis2/nightly), although you said you
are using axis2-1.3? . If so surely you will be working with the
latest fixes.

Thanks
Dimuthu

On Jan 23, 2008 5:34 PM, martin spurek <martin.spurek.fei@vsb.cz> wrote:
> Hello.
> I am using axis2c-bin-1.1.0-linux and axis2-1.3
> I am few past weeks learning how to use the generated adb stub using
> WSDL2C tool. I was doing as an exercise a simple wsdl service in java
> and i need to write test client in C. Using the generated stub took mi
> some time, however it compiles and work now.
> However, if I repeat calling generated
> axis2_stub_op_Service_EventPerformed(stub, env, _eventperformed1);
> function with every call it increase allocated memory (if i omit it the
> memry footprint is constant). It does not depend on whether the service
> is running or not, the continuous memory allocation is the same.  I am
> not really too familiar with the adb code, so i paste here the function
> where i call it and the generated stub. Maybe someone tells me where is
> the problem, thanks in advance.
> Martin
> -------------------------------------------------------------------------------
> FIRST function where i use it:
> -------------------------------------------------------------------------------
> RETURN_TYPE send_single_event(struct event_data *event){
>     printf ("AXIS2 sendout - single event... \n");
>     //following i keep still the same, declared on the top
>     if(EventDTO==NULL) EventDTO = adb_EventDTO_create(env);
>
>     status = adb_EventDTO_set_eventTime( EventDTO, env, event->time );
>     status = adb_EventDTO_set_cID( EventDTO, env, event->cID );
>     if(status != AXIS2_SUCCESS) return RETURN_FAILURE;
>
>     //following i keep still the same, declared on the top
>     if(_eventperformed1==NULL)   _eventperformed1 =
> adb_EventPerformed_create(env);
>
>     status = adb_EventPerformed_set_param0( _eventperformed1, env,
> EventDTO);
>     if(status != AXIS2_SUCCESS) return RETURN_FAILURE;
>
>     _eventperformedresponse2 =
> axis2_stub_op_Service_EventPerformed(stub, env, _eventperformed1);
>     if (_eventperformedresponse2 == NULL){
>         printf("\t!!! the service is not reachable at expected URI
> (wrong URI, service not is running or network connection failed)...\n");
>     } else {
>         printf(" - the Service_EventPerformed returns something...\n");
>         //free memory at the end of processing
>         adb_EventPerformedResponse_free(_eventperformedresponse2, env);
>         _eventperformedresponse2 = NULL;
>         // it frees also the serversResponseDTO, but does not NULL the
> pointer
>     }
>     return RETURN_SUCCESS;;
> }
> -------------------------------------------------------------------------------
> SECOND - the generated function i call
>     - i did not find yet how long are some pointers hold somewhere
> outside, however all the pointers in beginning are not freed locally
> -------------------------------------------------------------------------------
>     /**
>     * auto generated method signature
>     * for "EventPerformed|http://axis_interface.vsb.cz" operation.
>     *
>     * @param _EventPerformed
>     * @return
>     */
>     adb_EventPerformedResponse_t*
>     axis2_stub_op_Service_EventPerformed( axis2_stub_t *stub, const
> axutil_env_t *env,
>                     adb_EventPerformed_t* _EventPerformed)
> {
>
>
>     axis2_svc_client_t *svc_client = NULL;
>     axis2_options_t *options = NULL;
>     axiom_node_t *ret_node = NULL;
>
>     const axis2_char_t *soap_action = NULL;
>     axutil_qname_t *op_qname =  NULL;
>     axiom_node_t *payload = NULL;
>     axis2_bool_t is_soap_act_set = AXIS2_TRUE;
>
>     axutil_string_t *soap_act = NULL;
>     adb_EventPerformedResponse_t* ret_val = NULL;
>
>         payload = adb_EventPerformed_serialize(_EventPerformed, env,
> NULL, NULL, AXIS2_TRUE, NULL, NULL);
>
>
>     options = axis2_stub_get_options( stub, env);
>     if ( NULL == options )
>     {
>         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM,
> AXIS2_FAILURE);
>         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "options is null in stub");
>         return NULL;
>     }
>
>     svc_client = axis2_stub_get_svc_client(stub, env );
>     soap_action = axis2_options_get_action( options, env );
>     if (NULL == soap_action)
>     {
>         is_soap_act_set = AXIS2_FALSE;
>         soap_action = "urn:EventPerformed";
>         soap_act = axutil_string_create(env, "urn:EventPerformed");
>         axis2_options_set_soap_action(options, env, soap_act);
>         axis2_options_set_action( options, env, soap_action );
>     }
>
>     axis2_options_set_soap_version(options, env, AXIOM_SOAP11 );
>
>     op_qname = axutil_qname_create(env,
>                     "EventPerformed" ,
>                     "http://axis_interface.vsb.cz",
>                     NULL);
>     ret_node =  axis2_svc_client_send_receive_with_op_qname( svc_client,
> env, op_qname, payload);
>
>     if (!is_soap_act_set)
>     {
>       axis2_options_set_soap_action(options, env, NULL);
>       axis2_options_set_action( options, env, NULL);
>     }
>
>
>         if ( NULL == ret_node )
>         {
>             return NULL;
>         }
>         ret_val = adb_EventPerformedResponse_create(env);
>
>         if(adb_EventPerformedResponse_deserialize(ret_val, env,
> &ret_node, NULL, AXIS2_FALSE ) == AXIS2_FAILURE)
>         {
>             if(ret_val != NULL)
>             {
>               adb_EventPerformedResponse_free(ret_val, env);
>             }
>
>             AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "NULL returnted
> from the EventPerformedResponse_deserialize: "
>                                 "This should be due to an invalid XML");
>                         return NULL;
>         }
>         return ret_val;
>  }
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message