This is the mail archive of the
mailing list for the Guile project.
- To: Paul Kunysch <email@example.com>
- Subject: Re: garbage-collection
- From: Jost Boekemeier <firstname.lastname@example.org.TU-Berlin.DE>
- Date: 05 Aug 1999 23:30:59 +0200
- Cc: email@example.com
- References: <firstname.lastname@example.org>
Paul Kunysch <email@example.com> writes:
> Let's assume I call gh_str02scm("data") in a c program. This function
> returns a handle to the data. How does the garbage-collector know
> when do delete "data" from my memory?
The guile mark function marks everything it can find on the stack
and in other special places. An object that has no mark will
be collected in the sweep phase. Whenever you call a object constructor
(`scm_make_anything()') or call scm_must_malloc() directly, the
garbage collector may run.
> I suppose there is a function like "void gh_gc_unmark(SCM);"
SCM data = gh_str02scm("data");
/* remove reference to data object */
data = SCM_UNDEFINED; /* or SCM_BOOL_F,... */
xyz_object_my_data = scm_must_malloc(...) /* may invoke gc which removes data */
> The only thing I found was a comment containing "gh_gc_mark(SCM)" in
> "guile/gh.h". Does this mean that the SCM-handles point to data that
> is "not in use" by default?
When you create your own structures and you want to store scheme
objects in them, you have to mark the objects yourself with
gc_mark or gh_gc_mark().
> I'm trying to write a server that converts its input-requests to
> If all requests will stay in my memory forever I have a
> problem. A good explanation how arbage is collected would be nice.
The garbage collector is described in data-rep.texi. You may also
want to use smobs, look at the smob example in the docs directory.