axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manjula Peiris <manj...@wso2.com>
Subject Re: Freeing in axutil_array_list
Date Wed, 21 Nov 2007 03:54:45 GMT
Hi Edward,

Please see my comments inline.

On Tue, 2007-11-20 at 16:33 -0500, Liu_Edward@emc.com wrote:
> I did some investigation in the source code for axutil_array_list_free
> and I noticed that the individual array elements in array_list are not
> being freed up, just the entire data object.  From my diff, here is the
> change I made (lines starting with the plus):
> 
> Index: util/src/array_list.c
> ===================================================================
> --- util/src/array_list.c       (revision xxxx)
> +++ util/src/array_list.c       (working copy)
> @@ -258,7 +258,14 @@
> 
>      if (array_list->data)
>      {
> +       int i;
> +       for (i = 0; i < array_list->size; i++)
> +       {
> +               AXIS2_FREE(env->allocator, array_list->data[i]);
> +               array_list->data[i] = NULL;
> +       }
>          AXIS2_FREE(env->allocator, array_list->data);
> +       array_list->data = NULL;
>      }
>      AXIS2_FREE(env->allocator, array_list);
>      return;
> 
> With these new lines, I noticed that there is a slight improvement, with
> less memory leakage.  The increase in memory recovery is very
> beneficial, whether small or large, for me.  Is there a reason why the
> individual elements were not being freed up in the first place? 

Yes in the real situation we don't know what sort of data type is stored
in the arraylist. so we can't use AXIS2_FREE  to free those individual
elements. Those should be freed using there own free function. So it is
arraylist user's responsibility to free those individual elements.

-Manjula. 





> 
> Thanks,
> Edward
> 
> ---------------------------------------------------------------------
> 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