Hi Edward,

Please see my comments inline.

On Tue, 2007-11-20 at 16:33 -0500, [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to