From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p51JABHC005216 for ; Wed, 1 Jun 2011 21:10:11 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AukDACeO5k3RVaE2imdsb2JhbAA9AQMSmBiODQgUAQEBCgkNBxIGIYhxoiKMHoI5hDY5iGIBAQMGhhoEhl+JdoVWgxmCQzuDQQ X-IronPort-AV: E=Sophos;i="4.65,304,1304287200"; d="scan'208";a="110062920" Received: from mail-fx0-f54.google.com ([209.85.161.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 01 Jun 2011 21:10:06 +0200 Received: by fxm11 with SMTP id 11so526865fxm.27 for ; Wed, 01 Jun 2011 12:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type :content-transfer-encoding; bh=JlRelqMO8nfIQWv2bTf3CTR0QVMKcb7Gvg+PN63AI08=; b=twI6zk2vjaeKvun7oJycCw23Cj9J99Ny1murmGTlcIKP6HRRnJXSslMeY/mRzijj0M +2vG+b3Fbj7JxCtAP3gLawF5Zoqr2RzKdCJp2Bu1YvsK4nq8WdxaXdyoefhj82YBv3Tp uvCFYCHbaAlewBi8mxaaTZSHyV5b44d93Rbjo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=hjgPbFotdNeCLTNOmfHFr2naV2Zo+y/IJ34NKb2UgVhYG+/vr3A/xvVGPRcDmzzhED uQF02pRAIKO6vfY+NLcsv+7KT1hYyoBINqnfPgvQxOoDckCp4F19/Y2dBTikzoEcwbji VPQQzPBFok2Ry0d5tX8+co3qBb9qlTZBCFYVw= Received: by 10.223.62.146 with SMTP id x18mr1971778fah.54.1306955405788; Wed, 01 Jun 2011 12:10:05 -0700 (PDT) Received: from lemon.local.tld (63-83-133-95.pool.ukrtel.net [95.133.83.63]) by mx.google.com with ESMTPS id g7sm508406fac.39.2011.06.01.12.10.02 (version=SSLv3 cipher=OTHER); Wed, 01 Jun 2011 12:10:04 -0700 (PDT) Date: Wed, 1 Jun 2011 22:09:27 +0300 From: ygrek To: caml-list@inria.fr Message-Id: <20110601220927.84d72f80.ygrekheretix@gmail.com> In-Reply-To: References: X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Finding memory leakage using Gc module On Wed, 1 Jun 2011 14:40:06 +0200 Hans Ole Rafaelsen wrote: > Hi, > > is there some way to monitor memory being allocated (and still in use) when > calling a function? In the first case below it should report close to 0 and > in the second close to 10240. But here it reports 10368 in both cases. > Gc.allocated_bytes seems to report allocated bytes without reporting what it > was able to free. Have also tried other Gc functions such as Gc.counters. Is > it some way to find out which bytes have been allocated and not freed after > calling a function? Is there some good methods that people use to find out > (get a hint of) which memory is leaking? Using full_major (to empty minor heap) and looking at live_words works : open Gc let str = ref "" let f () = full_major (); let before = (stat ()).live_words in str := String.create 102400; str := ""; Gc.full_major (); let after = (stat ()).live_words in let delta = after - before in Printf.printf "Words used: %d\n%!" delta let g () = Gc.full_major (); let before = (stat ()).live_words in str := String.create 102400; Gc.full_major (); let after = (stat ()).live_words in let delta = after - before in Printf.printf "Words used: %d\n%!" delta -- ygrek http://ygrek.org.ua