help required regarding memory leak
To find out which bits of you code is causing the leak (if any), compile your code to include debug symbols (i.e. include -g flag if you're using gcc), then run your program via valgrind.
valgrind --leak-check=full ./your_program
The run will take a little longer than usual, but when your program ends, the output from valgrind should tell you how much memory you've leaked and where the cuplrits are.
Sample output:
==10934== HEAP SUMMARY:
==10934==     in use at exit: 10 bytes in 10 blocks
==10934==   total heap usage: 10 allocs, 0 frees, 10 bytes allocated
==10934== 
==10934== 10 bytes in 10 blocks are definitely lost in loss record 1 of 1
==10934==    at 0x4024F20: malloc (vg_replace_malloc.c:236)
==10934==    by 0x8048402: main (a.c:8)
==10934== 
==10934== LEAK SUMMARY:
==10934==    definitely lost: 10 bytes in 10 blocks
==10934==    indirectly lost: 0 bytes in 0 blocks
==10934==      possibly lost: 0 bytes in 0 blocks
==10934==    still reachable: 0 bytes in 0 blocks
==10934==         suppressed: 0 bytes in 0 blocks
update
Since you're already using valgrind, perhaps you could try using the Massif tool that comes with it. It should be able to paint a more accurate picture of memory usage (compare to simply watching top).
Check out this tutorial to see how it can be used. You may need some additional options to get a sensible graph depending on the runtime and mem usage of your program. Some useful options are described a few pages later in the tutorial.
Good luck.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论