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 SAA15861; Sat, 5 Jun 2004 18:30:14 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 SAA16097 for ; Sat, 5 Jun 2004 18:30:13 +0200 (MET DST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i55GUAEV003302 for ; Sat, 5 Jun 2004 18:30:11 +0200 Received: from [192.168.1.200] (ppp114-11.lns1.syd3.internode.on.net [150.101.114.11]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i55GTb4Y078552; Sun, 6 Jun 2004 01:59:38 +0930 (CST) Subject: Re: [Caml-list] Garbage collecting _everything_ From: skaller Reply-To: skaller@users.sourceforge.net To: Roberto Bagnara Cc: caml-list In-Reply-To: <40C1E87D.9030903@cs.unipr.it> References: <40C1E87D.9030903@cs.unipr.it> Content-Type: text/plain Message-Id: <1086452975.16811.474.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 06 Jun 2004 02:29:36 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 40C1F512.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sourceforge:01 2004:99 pervasives:01 9660:01 glebe:01 bindings:01 ocaml:01 garbage:01 nsw:01 snail:02 exception:02 checkout:02 uncaught:02 arbitrary:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, 2004-06-06 at 01:36, Roberto Bagnara wrote: > Isn't `at_exit Gc.full_major;;' supposed to collect > _everything_ at program termination time? Here is what it says about at_exit: Register the given function to be called at program termination time. The functions registered with at_exit will be called when the program executes Pervasives.exit, or terminates, either normally or because of an uncaught exception. The functions are called in ``last in, first out'' order: the function most recently added with at_exit is called first. Now, since these functions are *arbitrary*, performing a collection at some particular time will do just the same as it always does: collect unreachable objects. Clearly, global variables created thusly: let x = create_object () ;; may be visible to any function defined in the same scope subsequently. It is likely such variables must be considered visible to all functions. In other words, they all must be roots. The only time these objects could possibly be released is after all user code has executed, and that would be after all 'at_exit' functions have completed. So I am guessing that you made the mistake of placing two of your C++ objects in Ocaml global variables. Make sure the bindings for you test objects are to variables local to a test function which terminates and leaves its locals unreachable. You can simply call Gc.full_major after invoking the test function. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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