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 Frederic Heem <fr...@telsey.it> on 2008/05/20 19:17:51 UTC

valgrind and memory leaks

Hi folks,
Valgrind 3.3 is being mainly used to track memory leak, unfortunately, 
it doesn't catch memory allocated by the macro AXIS2_MALLOC, probably 
due to the fact that it uses a function pointer. Modifying the three 
macro as follows solves this problem and memory leaks can be finally 
detected during development.

#if 0
#define AXIS2_MALLOC(allocator, size) \
      ((allocator)->malloc_fn(allocator, size))

#define AXIS2_REALLOC(allocator, ptr, size) \
      ((allocator)->realloc(allocator, ptr, size))

#define AXIS2_FREE(allocator, ptr) \
      ((allocator)->free_fn(allocator, ptr))
#else
#include <stdlib.h>
#define AXIS2_MALLOC(allocator, size) \
      malloc(size)

#define AXIS2_REALLOC(allocator, ptr, size) \
      realloc(ptr, size)

#define AXIS2_FREE(allocator, ptr) \
      free(ptr)
#endif

Best Regards,
Frederic Heem




______________________________________________________________________________

--- NOTICE ---

This  email  and  any  attachments  are  confidential and are intended for the
addressee  only.  If you have received this message by mistake, please contact
us  immediately and  then  delete the message from your system.   You must not
copy, distribute, disclose  or  act upon the contents of this email.  Personal
and corporate data submitted will be used in a correct, transparent and lawful
manner. The data collected will be processed in paper or computerized form for
the  performance  of  contractual  and  lawful  obligations as well as for the
effective  management of business relationship.   The data processor is Telsey
S.p.A.   The  data  subject may exercise all the rights set forth in art. 7 of
Law  by  Decree  30.06.2003  n.  196   as   reported   in  the  following  url
http://www.telsey.com/privacy.asp.

______________________________________________________________________________
798t8RfNa6Dl8Ilf

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


Re: valgrind and memory leaks

Posted by Senaka Fernando <se...@wso2.com>.
Hi Dinesh,

Can't we use a conditional statement for the valgrind case? Therefore, if
someone needs to use the mechanism Frederic suggests, he needs to define
something. Simple as that.

Regards,
Senaka

> Hi Frederic,
>
> Frederic Heem <fr...@telsey.it> writes:
>
>> Hi folks,
>> Valgrind 3.3 is being mainly used to track memory leak, unfortunately,
>> it doesn't catch memory allocated by the macro AXIS2_MALLOC, probably
>> due to the fact that it uses a function pointer. Modifying the three
>> macro as follows solves this problem and memory leaks can be finally
>> detected during development.
>
> If we remove the function pointers as you suggest, it eliminates our
> design goal with function pointers. We used those function pointers in
> order to use other memory handling mechanisms other than malloc. As an
> example we use apr_pools underneath in mod_axis2 memory
> handling. Other thing is malloc may not be portable across different
> platforms.
>
> Therefore I don't think it is a good idea to remove those function
> pointers.
>
> thanks,
> Dinesh
> --
> http://nethu.org
>
> ---------------------------------------------------------------------
> 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: valgrind and memory leaks

Posted by Frederic Heem <fr...@telsey.it>.
Dinesh Premalal wrote:
> Hi Frederic,
>
> Frederic Heem <fr...@telsey.it> writes:
>
>   
>> Hi folks,
>> Valgrind 3.3 is being mainly used to track memory leak, unfortunately,
>> it doesn't catch memory allocated by the macro AXIS2_MALLOC, probably
>> due to the fact that it uses a function pointer. Modifying the three
>> macro as follows solves this problem and memory leaks can be finally
>> detected during development.
>>     
>
> If we remove the function pointers as you suggest, it eliminates our
> design goal with function pointers. We used those function pointers in
> order to use other memory handling mechanisms other than malloc. As an
> example we use apr_pools underneath in mod_axis2 memory
> handling. Other thing is malloc may not be portable across different 
> platforms. 
>
> Therefore I don't think it is a good idea to remove those function
> pointers. 
>
> thanks,
> Dinesh
>   
The changes I propose must not be commit to subversion, it is just a 
kludge for this valgrind bug. However, this change can used only during 
development to catch memory leak.
Frederic

-- 
---

Frederic Heem - Innovation Hub Senior Engineer
Telsey Telecommunications S.p.A.
email: frederic.heem@telsey.it
Departement: Innovation Hub
UK: Vanguard Centre, ATU II, Unit 8    Sir William Lyons Road University of Warwick Science Park    CV4 7EZ Coventry
Tel. direct phone (+39) 0422 377760
Central Bureau       Viale dell'Industria, 1
31055 Quinto di Treviso (TV)  - Italy
Tel.: +39 0422470840  Fax: +39 0422470920
Web: www.telsey.com






______________________________________________________________________________

--- NOTICE ---

This  email  and  any  attachments  are  confidential and are intended for the
addressee  only.  If you have received this message by mistake, please contact
us  immediately and  then  delete the message from your system.   You must not
copy, distribute, disclose  or  act upon the contents of this email.  Personal
and corporate data submitted will be used in a correct, transparent and lawful
manner. The data collected will be processed in paper or computerized form for
the  performance  of  contractual  and  lawful  obligations as well as for the
effective  management of business relationship.   The data processor is Telsey
S.p.A.   The  data  subject may exercise all the rights set forth in art. 7 of
Law  by  Decree  30.06.2003  n.  196   as   reported   in  the  following  url
http://www.telsey.com/privacy.asp.

______________________________________________________________________________
798t8RfNa6Dl8Ilf

Re: valgrind and memory leaks

Posted by Dinesh Premalal <xy...@gmail.com>.
Hi Frederic,

Frederic Heem <fr...@telsey.it> writes:

> Hi folks,
> Valgrind 3.3 is being mainly used to track memory leak, unfortunately,
> it doesn't catch memory allocated by the macro AXIS2_MALLOC, probably
> due to the fact that it uses a function pointer. Modifying the three
> macro as follows solves this problem and memory leaks can be finally
> detected during development.

If we remove the function pointers as you suggest, it eliminates our
design goal with function pointers. We used those function pointers in
order to use other memory handling mechanisms other than malloc. As an
example we use apr_pools underneath in mod_axis2 memory
handling. Other thing is malloc may not be portable across different 
platforms. 

Therefore I don't think it is a good idea to remove those function
pointers. 

thanks,
Dinesh
-- 
http://nethu.org

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