From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Abhijeet More Newsgroups: gmane.lisp.guile.user Subject: Re: Possible Memory Leak with stream-for-each Date: Wed, 11 Aug 2010 12:57:13 -0400 Message-ID: References: <87iq44yi1q.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1281546341 14988 80.91.229.12 (11 Aug 2010 17:05:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 11 Aug 2010 17:05:41 +0000 (UTC) Cc: =?ISO-8859-1?Q?Ludovic_Court=E8s?= , guile-user@gnu.org, Tibi Turbureanu To: Andy Wingo Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Aug 11 19:05:38 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OjEkD-0003wv-HT for guile-user@m.gmane.org; Wed, 11 Aug 2010 19:05:37 +0200 Original-Received: from localhost ([127.0.0.1]:44561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OjEkD-00071J-04 for guile-user@m.gmane.org; Wed, 11 Aug 2010 13:05:37 -0400 Original-Received: from [140.186.70.92] (port=46912 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OjEjz-0006lf-JC for guile-user@gnu.org; Wed, 11 Aug 2010 13:05:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OjEc7-0001C2-DJ for guile-user@gnu.org; Wed, 11 Aug 2010 12:57:17 -0400 Original-Received: from mail-qw0-f41.google.com ([209.85.216.41]:44629) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OjEc7-0001Bn-AF; Wed, 11 Aug 2010 12:57:15 -0400 Original-Received: by qwk4 with SMTP id 4so389593qwk.0 for ; Wed, 11 Aug 2010 09:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=MjIsW9qeAlFRx70xaDRVQTHx1vLXrtl7fry6I9VVXwM=; b=fvl3serhSqad6Rrr4hymdGdcInfOW5yNbN2AY+9dmBBJrOnj9fikWtK5wTKm34a5jZ udR4OVsbUfOuizzZhw5f+s8a7JaHSO4jO0+VOoAPLvnY3+dRWsn3EecSGtJHE8/DuxBi Ipm2B4wOQckAwdAbqyJDiEulI5npFYl8MC5sA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=ag4n2sc22pyy6/+0adrEECq9MEPCJDQASwSelkNErNJ0K3B2n10VER5nif2vIMox0q Bt0rc/Z8FfaPVL8foG5MmvV3igffE5Qr8HE9fOqS/1srtN6DIgAscAWt+b+doTQBiOe7 kRFek9KiWihfDsh1Xe8pmawlG9Y6cAwix94IM= Original-Received: by 10.224.28.70 with SMTP id l6mr11050421qac.348.1281545833556; Wed, 11 Aug 2010 09:57:13 -0700 (PDT) Original-Received: by 10.229.184.145 with HTTP; Wed, 11 Aug 2010 09:57:13 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8056 Archived-At: On Sat, Jul 31, 2010 at 4:16 PM, Abhijeet More wrote: > Andy, > Thanks! That's a great answer! > I'll see what I can do with these guidelines. Apologies - I haven't had a chance yet to look into using the libgc library as you suggested. Would it be possible to use valgrind massif instead of changing the code to see what we need? Also: I was trying to write an implementation that did not leak and came across the following. When I redefine "delay" and "force" as follows: (defmacro delay (expr) `(make-promise (lambda() ,expr))) (define (make-promise proc) (lambda() (proc))) (define force (lambda (promise) (promise))) there is no memory leak. I see a leak again when I introduce memoization into the "make-promise" implementation above. To me it looks like that the leak that we see is caused by memoization of the "promise" objects created by guile's default version of force and delay. At what point does guile decide that a memoization isn't required anymore? At this point I don't know guile code well enough to say this for sure. Thanks Abhijeet