Note that there are some explanatory texts on larger screens.

plurals
  1. POPossible memory leak problem
    primarykey
    data
    text
    <p><strong>I write two pieces of c programs like following, during memcheck process using Valgrind, a lot of mem leak information is given.</strong></p> <pre><code>int GetMemory(int framewidth, int frameheight, int SR/*, int blocksize*//*,int ALL_REF_NUM*/) { //int i,j; int memory_size = 0; //int refnum = ALL_REF_NUM; int input_search_range = SR; memory_size += get_mem2D(&amp;curFrameY, frameheight, framewidth); memory_size += get_mem2D(&amp;curFrameU, frameheight&gt;&gt;1, framewidth&gt;&gt;1); memory_size += get_mem2D(&amp;curFrameV, frameheight&gt;&gt;1, framewidth&gt;&gt;1); memory_size += get_mem3D(&amp;prevFrameY, refnum, frameheight, framewidth);// to allocate reference frame buffer accoding to the reference frame number memory_size += get_mem3D(&amp;prevFrameU, refnum, frameheight&gt;&gt;1, framewidth&gt;&gt;1); memory_size += get_mem3D(&amp;prevFrameV, refnum, frameheight&gt;&gt;1, framewidth&gt;&gt;1); memory_size += get_mem2D(&amp;mpFrameY, frameheight, framewidth); memory_size += get_mem2D(&amp;mpFrameU, frameheight&gt;&gt;1, framewidth&gt;&gt;1); memory_size += get_mem2D(&amp;mpFrameV, frameheight&gt;&gt;1, framewidth&gt;&gt;1); memory_size += get_mem2D(&amp;searchwindow, input_search_range*2 + blocksize, input_search_range*2 + blocksize);// to allocate search window according to the searchrange /*memory_size +=*/ get_mem1D(/*&amp;SAD_cost, height, width*/); // memory_size += get_mem2D(&amp;searchwindow, 80, 80);// if searchrange is 32, then only 32+1+32+15 pixels is needed in each row and col, therefore the range of // search window is enough to be set to 80 ! memory_size += get_mem2Dint(&amp;all_mv, height/blocksize, width/blocksize); return 0; } void FreeMemory(int refno) { free_mem2D(curFrameY); free_mem2D(curFrameU); free_mem2D(curFrameV); free_mem3D(prevFrameY,refno); free_mem3D(prevFrameU,refno); free_mem3D(prevFrameV,refno); free_mem2D(mpFrameY); free_mem2D(mpFrameU); free_mem2D(mpFrameV); free_mem2D(searchwindow); free_mem1D(); free_mem2Dint(all_mv); } void free_mem1D() { free(SAD_cost); } </code></pre> <p><strong>Now I hope to make sure where are the possible problems in my program? Here I may post some valgrind information to let you know about the actual error information.</strong></p> <p>==29105== by 0x804A906: main (me_search.c:1480)</p> <p>==29105== </p> <p>==29105== </p> <p>==29105== HEAP SUMMARY:</p> <p>==29105== in use at exit: 124,088 bytes in 18 blocks</p> <p>==29105== total heap usage: 37 allocs, 21 frees, 749,276 bytes allocated</p> <p>==29105== </p> <p>==29105== 272 bytes in 1 blocks are still reachable in loss record 1 of 18</p> <p>==29105== at 0x402425F: calloc (vg_replace_malloc.c:467)</p> <p>==29105== by 0x804A296: get_mem2D (me_search.c:1315)</p> <p>==29105== by 0x804885E: GetMemory (me_search.c:117)</p> <p>==29105== by 0x804A757: main (me_search.c:1456)</p> <p>==29105== </p> <p>==29105== 352 bytes in 1 blocks are still reachable in loss record 2 of 18</p> <p>==29105== at 0x4024F20: malloc (vg_replace_malloc.c:236)</p> <p>==29105== by 0x409537E: __fopen_internal (iofopen.c:76)</p> <p>==29105== by 0x409544B: fopen@@GLIBC_2.1 (iofopen.c:107)</p> <p>==29105== by 0x804A660: main (me_search.c:1439)</p> <p>==29105== </p> <p>==29105== 584 bytes in 1 blocks are still reachable in loss record 3 of 18</p> <p>==29105== at 0x402425F: calloc (vg_replace_malloc.c:467)</p> <p>==29105== by 0x804A296: get_mem2D (me_search.c:1315)</p> <p>==29105== by 0x8048724: GetMemory (me_search.c:106)</p> <p>==29105== by 0x804A757: main (me_search.c:1456)</p> <p>==29105== </p> <p>==29105== 584 bytes in 1 blocks are still reachable in loss record 4 of 18</p> <p>==29105== at 0x402425F: calloc (vg_replace_malloc.c:467)</p> <p>==29105== by 0x804A296: get_mem2D (me_search.c:1315)</p> <p>==29105== by 0x8048747: GetMemory (me_search.c:107)</p> <p>==29105== by 0x804A757: main (me_search.c:1456)</p> <p>==29105== </p> <p>==29105== 584 bytes in 1 blocks are still reachable in loss record 5 of 18</p> <p>==29105== at 0x402425F: calloc (vg_replace_malloc.c:467)</p> <p>==29105== by 0x804A296: get_mem2D (me_search.c:1315)</p> <p>==29105== by 0x8048809: GetMemory (me_search.c:114)</p> <p>==29105== by 0x804A757: main (me_search.c:1456)</p> <p>==29105== </p> <p>==29105== 584 bytes in 1 blocks are still reachable in loss record 6 of 18</p> <p>==29105== at 0x402425F: calloc (vg_replace_malloc.c:467)</p> <p>==29105== by 0x804A296: get_mem2D (me_search.c:1315)</p> <p>==29105== by 0x804882C: GetMemory (me_search.c:115)</p> <p>==29105== by 0x804A757: main (me_search.c:1456)</p> <p>==29105== </p> <p>==29105== 584 bytes in 1 blocks are definitely lost in loss record 7 of 18</p> <p>==29105== at 0x402425F: calloc (vg_replace_malloc.c:467)</p> <p>==29105== by 0x804A296: get_mem2D (me_search.c:1315)</p> <p>==29105== by 0x804A4F8: get_mem3D (me_search.c:1393)</p> <p>==29105== by 0x804879B: GetMemory (me_search.c:110)</p> <p>==29105== by 0x804A757: main (me_search.c:1456)</p> <p>==29105== </p> <p>==29105== 584 bytes in 1 blocks are definitely lost in loss record 8 of 18</p> <p>==29105== at 0x402425F: calloc (vg_replace_malloc.c:467)</p> <p>==29105== by 0x804A296: get_mem2D (me_search.c:1315)</p> <p>==29105== by 0x804A4F8: get_mem3D (me_search.c:1393)</p> <p>==29105== by 0x80487C9: GetMemory (me_search.c:111)</p> <p>==29105== by 0x804A757: main (me_search.c:1456)</p> <p>==29105== </p> <p>==29105== 1,168 bytes in 1 blocks are still reachable in loss record 9 of 18</p> <p>==29105== at 0x402425F: calloc (vg_replace_malloc.c:467)</p> <p>==29105== by 0x804A296: get_mem2D (me_search.c:1315)</p> <p>==29105== by 0x8048701: GetMemory (me_search.c:105)</p> <p>==29105== by 0x804A757: main (me_search.c:1456)</p> <p>==29105== </p> <p>==29105== 1,168 bytes in 1 blocks are still reachable in loss record 10 of 18</p> <p>==29105== at 0x402425F: calloc (vg_replace_malloc.c:467)</p> <p>==29105== by 0x804A296: get_mem2D (me_search.c:1315)</p> <p>==29105== by 0x80487E6: GetMemory (me_search.c:113)</p> <p>==29105== by 0x804A757: main (me_search.c:1456)</p> <p>==29105== </p> <p>==29105== 1,168 bytes in 1 blocks are definitely lost in loss record 11 of 18</p> <p>==29105== at 0x402425F: calloc (vg_replace_malloc.c:467)</p> <p>==29105== by 0x804A296: get_mem2D (me_search.c:1315)</p> <p>==29105== by 0x804A4F8: get_mem3D (me_search.c:1393)</p> <p>==29105== by 0x804876D: GetMemory (me_search.c:109)</p> <p>==29105== by 0x804A757: main (me_search.c:1456)</p> <p>==29105== </p> <p>==29105== 6,336 bytes in 1 blocks are definitely lost in loss record 12 of 18</p> <p>==29105== at 0x4024F20: malloc (vg_replace_malloc.c:236)</p> <p>==29105== by 0x804A25C: get_mem1D (me_search.c:1295)</p> <p>==29105== by 0x8048866: GetMemory (me_search.c:119)</p> <p>==29105== by 0x804A757: main (me_search.c:1456)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload