Fri 11 May 2007 09:31:01 AM UTC, original submission:
Hello world,
For my project, in order to find memory leak, i use valgrind with options --tool=memcheck --leak-check=yes --num-callers=20 .
In this way, i find some memory leaks on tsp_consumer.c. I try to investigate but i don't find all of solutions.
In tsp_consumer.c method tsp_consumer_request_sample():
476 bytes in 43 blocks are definitely lost in loss record 306 of 368
>malloc (vg_replace_malloc.c:149)
>strdup (in /lib/tls/libc-2.3.4.so)
>TSP_SSI_copy (tsp_common_ssi.c:210)
>TSP_SSIList_copy (tsp_common_ssi.c:313)
>TSP_consumer_request_sample (tsp_consumer.c:988)
Possible solution:
Add the line " TSP_SSIList_finalize(&(req_sample.symbols));
" at 1013 to desallocate the name of each elements of the list req_sample.symbols
In tsp_consumer.c method tsp_consumer_request_sample():
1,795 (1,400 direct, 395 indirect) bytes in 3 blocks are definitely lost in loss record 322 of 368
at 0x40056BF: calloc (vg_replace_malloc.c:279)
by 0xA52FCD: xdr_array (in /lib/tls/libc-2.3.4.so)
by 0x433558D: xdr_TSP_sample_symbol_info_list_t (tsp_rpc_xdr.c:470)
by 0x4335FFB: xdr_TSP_answer_sample_t (tsp_rpc_xdr.c:697)
by 0xA4C91A: clnttcp_call (in /lib/tls/libc-2.3.4.so)
by 0x4333BBC: tsp_request_sample_1 (tsp_rpc_clnt.c:104)
by 0x4337A5E: TSP_request_sample (tsp_client.c:248)
by 0x432FA25: TSP_consumer_request_sample (tsp_consumer.c:991)
I think the pb is the desallocation of ans_sample
I try this correction but the mem leak is not complety correct:
at line 1056
if(ans_sample->symbols.TSP_sample_symbol_info_list_t_val)
{
for (i = 0 ; i < ans_sample->symbols.TSP_sample_symbol_info_list_t_len ; i++)
{
/* free strdup */
free(ans_sample->symbols.TSP_sample_symbol_info_list_t_val[i].name);
}
}
In tsp_consumer.c method tsp_consumer_request_sample_init():
at 0x4004405: malloc (vg_replace_malloc.c:149)
by 0xA52DAE: xdr_string (in /lib/tls/libc-2.3.4.so)
by 0x433637B: xdr_TSP_answer_sample_init_t (tsp_rpc_xdr.c:764)
by 0xA4C91A: clnttcp_call (in /lib/tls/libc-2.3.4.so)
by 0x4333C46: tsp_request_sample_init_1 (tsp_rpc_clnt.c:119)
by 0x4337C32: TSP_request_sample_init (tsp_client.c:263)
by 0x433083F: TSP_consumer_request_sample_init (tsp_consumer.c:1116)
possible solution:
/desallocation of ans_sample/
if(ans_sample->data_address!=NULL)
{ free(ans_sample->data_address);}
I think you may be have the problem of desallocation of ans_sample on other tsp request .
If you have time to look at desallocation in tsp_consumer.c ....
Thanks in advance
---
Sarah
|