From: skaller <skaller@users.sourceforge.net>
To: Roberto Bagnara <bagnara@cs.unipr.it>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Garbage collecting _everything_
Date: 06 Jun 2004 02:29:36 +1000 [thread overview]
Message-ID: <1086452975.16811.474.camel@pelican.wigram> (raw)
In-Reply-To: <40C1E87D.9030903@cs.unipr.it>
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
next prev parent reply other threads:[~2004-06-05 16:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-05 15:36 Roberto Bagnara
2004-06-05 16:03 ` Daniel Bünzli
2004-06-05 16:11 ` Daniel Bünzli
2004-06-05 16:29 ` skaller [this message]
2004-06-05 16:50 ` Richard Jones
2004-06-05 19:46 ` Roberto Bagnara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1086452975.16811.474.camel@pelican.wigram \
--to=skaller@users.sourceforge.net \
--cc=bagnara@cs.unipr.it \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox