From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 3E646BBAF for ; Wed, 24 Nov 2010 04:54:32 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEACcb7EyD/NBugWdsb2JhbACichYBFiIitHCIaYVMBIRahgU X-IronPort-AV: E=Sophos;i="4.59,246,1288566000"; d="scan'208,217";a="80821822" Received: from expn.cat.pdx.edu ([131.252.208.110]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Nov 2010 04:54:31 +0100 Received: from svl2 (svl2.cs.pdx.edu [131.252.219.78]) by expn.cat.pdx.edu (8.14.3/8.14.3/Debian-9.1ubuntu1) with SMTP id oAO3sPe2031458 for ; Tue, 23 Nov 2010 19:54:25 -0800 Date: Tue, 23 Nov 2010 19:54:24 -0800 From: "Kecheng" To: "caml-list" Subject: OCaml memory leak issue Message-ID: <201011231954241577004@cecs.pdx.edu> X-mailer: Foxmail 6, 15, 201, 22 [cn] Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=====003_Dragon344284003543_=====" X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.4 (expn.cat.pdx.edu [131.252.208.110]); Tue, 23 Nov 2010 19:54:25 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on expn.cat.pdx.edu X-Virus-Scanned: clamav-milter 0.96.1 at expn.cat.pdx.edu X-Virus-Status: Clean X-Spam: no; 0.00; ocaml:01 ocaml:01 byte:01 printf:01 byte:01 malloc:01 malloc:01 pointer:01 printf:01 pointer:01 1.5:98 1.5:98 997:98 997:98 W6:98 This is a multi-part message in MIME format. --=====003_Dragon344284003543_===== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 --=====003_Dragon344284003543_===== Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: 7bit
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
--=====003_Dragon344284003543_=====--