Hi,
 
I used valgrind to check the memory usage of my OCaml byte code, but I found that a memory leak. I'm very confused what the problem is. I tried a very simple code as following, and compileed it.
 
+++++++++++++++++++++++
let test  =
    let a = 1 in
    let b = a + 5 in
    printf "%d\n" b;
;;
test;;
+++++++++++++++++++++++
 
And I run valgrind to check:
 
valgrind --leak-check=yes ./obj/x86_LINUX/test5.byte.exe
 
I got the following report:
==21692== Memcheck, a memory error detector
==21692== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==21692== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==21692== Command: ./obj/x86_LINUX/test5.byte.exe
==21692==
6
==21692==
==21692== HEAP SUMMARY:
==21692==     in use at exit: 430,488 bytes in 20 blocks
==21692==   total heap usage: 68 allocs, 48 frees, 446,837 bytes allocated
==21692==
==21692== 120 bytes in 1 blocks are definitely lost in loss record 9 of 17
==21692==    at 0x4A05E1C: malloc (vg_replace_malloc.c:195)
==21692==    by 0x9AA510: caml_init_major_heap (in /home/kecheng/symbolic_simulation/cvc_test/cvc_1.5/obj/x86_LINUX/test5.byte.exe)
==21692==    by 0x9A2A1A: caml_init_gc (in /home/kecheng/symbolic_simulation/cvc_test/cvc_1.5/obj/x86_LINUX/test5.byte.exe)
==21692==    by 0x997E9D: caml_main (in /home/kecheng/symbolic_simulation/cvc_test/cvc_1.5/obj/x86_LINUX/test5.byte.exe)
==21692==    by 0x9981CB: main (in /home/kecheng/symbolic_simulation/cvc_test/cvc_1.5/obj/x86_LINUX/test5.byte.exe)
==21692==
==21692== LEAK SUMMARY:
==21692==    definitely lost: 120 bytes in 1 blocks
==21692==    indirectly lost: 0 bytes in 0 blocks
==21692==      possibly lost: 0 bytes in 0 blocks
==21692==    still reachable: 430,368 bytes in 19 blocks
==21692==         suppressed: 0 bytes in 0 blocks
==21692== Reachable blocks (those to which a pointer was found) are not shown.
==21692== To see them, rerun with: --leak-check=full --show-reachable=yes
==21692==
==21692== For counts of detected and suppressed errors, rerun with: -v
==21692== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)
 
 
 
 
Kecheng
2010-11-23