From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA00697; Thu, 18 Apr 2002 23:02:19 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA00678 for caml-list@pauillac.inria.fr; Thu, 18 Apr 2002 23:02:15 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA22021 for ; Wed, 17 Apr 2002 16:53:57 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from sj1-3-4-9.securesites.net (sj1-3-4-9.securesites.net [192.220.127.202]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id g3HErtX13055 for ; Wed, 17 Apr 2002 16:53:56 +0200 (MET DST) Received: (qmail 23714 invoked by uid 16863); 17 Apr 2002 14:53:53 -0000 Received: from unknown (HELO localhost) ([192.220.65.223]) (envelope-sender ) by 192.220.65.223 (qmail-ldap-1.03) with SMTP for ; 17 Apr 2002 14:53:53 -0000 Date: Wed, 17 Apr 2002 14:53:48 +0000 (GMT) From: Brian Rogoff To: Markus Mottl cc: Scott Cyphers , Martin Jambon , Subject: Re: [Caml-list] Memory leak In-Reply-To: <20020417092252.GA20621@kiefer.ai.univie.ac.at> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 17 Apr 2002, Markus Mottl wrote: > On Tue, 16 Apr 2002, Scott Cyphers wrote: > > > Sure. There was a great demo of this on the translator's list for the > > > O'Reilly book; create a representation of stacks based on arrays with a > > > top of stack index. Popping items off of the stack by moving the TOS > > > pointer around won't free them. Could you be doing something like that? > > > > In that particular case, the stack implementation is a lot uglier when you > > need to provide the ability to neutralize array elements of arbitrary type > > as you pop the stack. Sometimes you get lulled into thinking the GC works > > completely invisibly. > > In case you ever need such functionality (stacks based on arrays), you > might want to try the library of resizable arrays called RES, which also > handles resizable strings: > > http://www.ai.univie.ac.at/~markus/home/ocaml_sources.html Hey, don't they say "Never use Obj.magic!"? ;-) I thought the issue that Scott caught on the translator's list was nice, and very easy to overlook. The safe way to do this without using magic is to either change the interface to provide a value of the element type or to use options underneath and add another level of packing and unpacking. I don't know if that issue is FAQ worthy, but it belongs in some kind of "gotcha" list for Caml programmers. Really anyone using a GCed language with arrays may see that one... -- Brian ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners