Re: Big memory leak in division operator example !
- Posted by Domingo Alvarez Duarte <domingo at dad-it.com> Jun 20, 2007
- 672 views
First valgrind report for program: ---------- include machine.e include get.e integer N atom x, y, z object Void constant RAND_MAX = 1073741823 N = 10 puts (1, "No memory leak till now !!!\nstarting division...\n") Void = wait_key () for i = 0 to N -1 do x = 50.0 - (100.0*rand(RAND_MAX)/(RAND_MAX+1.0)) y = 50.0 - (100.0*rand(RAND_MAX)/(RAND_MAX+1.0)) z = 50.0 - (100.0*rand(RAND_MAX)/(RAND_MAX+1.0)) end for puts (1, "Look at the memory leak now !!!!\nfinished...\n") Void = wait_key () ------------- The above is a simplified program to don't wait too much for valgrind analyse it, I called it test-memory-check2.exu. command used with euphoria compiled with "-g" flag added: valgrind --leak-check=yes exu test-memory-check2.exu ----------- $ valgrind --leak-check=yes exu test-memory-leak2.exu ==13416== Memcheck, a memory error detector. ==13416== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al. ==13416== Using LibVEX rev 1658, a library for dynamic binary translation. ==13416== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP. ==13416== Using valgrind-3.2.1-Debian, a dynamic binary instrumentation framework. ==13416== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al. ==13416== For more details, rerun with: -v ==13416== No memory leak till now !!! starting division... Look at the memory leak now !!!! finished... ==13416== ==13416== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 15 from 1) ==13416== malloc/free: in use at exit: 119,365 bytes in 2,719 blocks. ==13416== malloc/free: 10,156 allocs, 7,437 frees, 543,167 bytes allocated. ==13416== For counts of detected errors, rerun with: -v ==13416== searching for pointers to 2,719 not-freed blocks. ==13416== checked 338,024 bytes. ==13416== ==13416== 8 bytes in 1 blocks are definitely lost in loss record 2 of 19 ==13416== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13416== by 0x8085025: eu_startup (be_runtime.c:3624) ==13416== by 0x8049050: (within /home/mingo/euphoria/bin/exu) ==13416== ==13416== ==13416== 48 bytes in 4 blocks are definitely lost in loss record 5 of 19 ==13416== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13416== by 0x808C07E: Dminus (be_inline.c:46) ==13416== ==13416== ==13416== 100 bytes in 1 blocks are definitely lost in loss record 8 of 19 ==13416== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13416== by 0x808F44E: InitTask (be_task.c:242) ==13416== by 0x8049050: (within /home/mingo/euphoria/bin/exu) ==13416== ==13416== ==13416== 168 bytes in 14 blocks are definitely lost in loss record 10 of 19 ==13416== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13416== by 0x808BFC6: NewDouble (be_inline.c:46) ==13416== by 0x8049050: (within /home/mingo/euphoria/bin/exu) ==13416== ==13416== ==13416== 1,932 bytes in 6 blocks are definitely lost in loss record 14 of 19 ==13416== at 0x402071B: realloc (vg_replace_malloc.c:306) ==13416== by 0x8085F3D: Append (be_runtime.c:689) ==13416== ==13416== ==13416== 7,800 bytes in 49 blocks are possibly lost in loss record 15 of 19 ==13416== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13416== by 0x808D99B: machine (be_machine.c:2523) ==13416== ==13416== ==13416== 47,776 bytes in 537 blocks are definitely lost in loss record 19 of 19 ==13416== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13416== by 0x8089CFA: NewS1 (be_alloc.c:752) ==13416== by 0x8049050: (within /home/mingo/euphoria/bin/exu) ==13416== ==13416== LEAK SUMMARY: ==13416== definitely lost: 50,032 bytes in 563 blocks. ==13416== possibly lost: 7,800 bytes in 49 blocks. ==13416== still reachable: 61,533 bytes in 2,107 blocks. ==13416== suppressed: 0 bytes in 0 blocks. ==13416== Reachable blocks (those to which a pointer was found) are not shown. ==13416== To see them, rerun with: --show-reachable=yes