unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Brett Viren <bv@bnl.gov>
Cc: Guile user <guile-user@gnu.org>
Subject: Re: C++ application linked with guile dos not quite
Date: Tue, 18 Jun 2002 10:45:29 -0400	[thread overview]
Message-ID: <15631.18313.578397.245899@minos.phy.bnl.gov> (raw)
In-Reply-To: <1024411071.6804.3.camel@tice>

Hilaire Fernandes writes:
 > I do not use any scm_ methods actualy, I do not know anything about
 > them. I do not know if guile use it internaly then wait for it to be
 > unprotected.

I don't think there is ever a time that you must call
scm_unprotect_object() unless you explicitly called
scm_protect_object().

 > Well I am wondering what is for scm_protect_object().

You would only need scm_protect_object() on any SCM if two cases are
met:

1) you store the SCM in your C/C++ code for multiple calls to gh_ or
scm_ functions (ie, any time that a garbage collection might happen).

2) If there is any chance that all internal references to the SCM will
disappear.

Since garbage collection looks at reference counts, if your C/C++ code
is still referring to an SCM, but nothing on the guile side is, then
the ref count can go to zero and the GC thinks it's okay to reap the
SCM (since it doesn't know about your C/C++ reference).  The
protect/unprotect just increments/decrements the ref count.

 > Is there some special procedure to free memory from a SCM object?
 > For example the value returned by a call to guile procedure?

Not that I know of.  I have always done things via
scm_(un)protect_object().  

BTW, you can force a garbage collection via scm_gc().  Durring
debugging I would call this once per "cycle" of my program.  This
greatly slowed things down, but it will trigger a SegV immediately so
it is easier to know when something is going wrong.

Again, I am no expert, but since the experts seem to be quiet today, I
hope this helps.

-Brett.

_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


  reply	other threads:[~2002-06-18 14:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-17 13:24 C++ application linked with guile dos not quite Hilaire Fernandes
2002-06-18  8:25 ` CDDP 40 - TICE
2002-06-18 13:43   ` Brett Viren
2002-06-18 14:37     ` Hilaire Fernandes
2002-06-18 14:45       ` Brett Viren [this message]
2002-06-18 17:26     ` Marius Vollmer
2002-06-19  8:02       ` CDDP 40 - TICE
2002-06-19 11:14         ` Marius Vollmer
2002-06-19 13:19           ` CDDP 40 - TICE
2002-06-19 14:09             ` Brett Viren
2002-06-19 16:42               ` CDDP 40 - TICE
  -- strict thread matches above, loose matches on Subject: below --
2002-06-17 13:23 CDDP

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

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15631.18313.578397.245899@minos.phy.bnl.gov \
    --to=bv@bnl.gov \
    --cc=guile-user@gnu.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).