From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Whitlock, Bradley D" Newsgroups: gmane.lisp.guile.user Subject: Guile 1.8 Garbage Collection Question Date: Tue, 25 Oct 2011 20:34:23 +0000 Message-ID: <1B716C7666FD684A9FDF0FBD5EE5E0A0156F8529@HDXDSP11.us.lmco.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="Boundary_(ID_ThVbqZXy1xK9rvCClestnA)" X-Trace: dough.gmane.org 1319574888 32084 80.91.229.12 (25 Oct 2011 20:34:48 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 25 Oct 2011 20:34:48 +0000 (UTC) To: "guile-user@gnu.org" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Oct 25 22:34:44 2011 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RInhq-0004dc-O0 for guile-user@m.gmane.org; Tue, 25 Oct 2011 22:34:43 +0200 Original-Received: from localhost ([::1]:57773 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RInhq-0003Ft-9m for guile-user@m.gmane.org; Tue, 25 Oct 2011 16:34:42 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:39852) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RInhk-0003Fm-It for guile-user@gnu.org; Tue, 25 Oct 2011 16:34:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RInhi-0007uD-Nf for guile-user@gnu.org; Tue, 25 Oct 2011 16:34:36 -0400 Original-Received: from mailfo01.lmco.com ([192.31.106.12]:45001) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RInhi-0007tv-Fc for guile-user@gnu.org; Tue, 25 Oct 2011 16:34:34 -0400 Original-Received: from mailgw3a.lmco.com (mailgw3a.lmco.com [192.35.35.7]) by mailfo01.lmco.com (8.14.3/8.14.3) with ESMTP id p9PKYT40009898 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Tue, 25 Oct 2011 21:34:30 +0100 Original-Received: from emss09g01.ems.lmco.com (relay6.ems.lmco.com [166.17.13.59])by mailgw3a.lmco.com (LM-6) with ESMTP id p9PKYTgm023109for ; Tue, 25 Oct 2011 16:34:29 -0400 (EDT) Original-Received: from CONVERSION2-DAEMON.lmco.com by lmco.com (PMDF V6.4 #31806) id <0LTN005012HHK9@lmco.com> for guile-user@gnu.org; Tue, 25 Oct 2011 20:34:29 +0000 (GMT) Original-Received: from HDXHTPN7.us.lmco.com ([158.188.83.14]) by lmco.com (PMDF V6.4 #31806) with ESMTP id <0LTN008312HB4L@lmco.com> for guile-user@gnu.org; Tue, 25 Oct 2011 20:34:24 +0000 (GMT) Original-Received: from HDXDSP11.us.lmco.com ([fe80::c04a:c222:3486:3e3]) by HDXHTPN7.us.lmco.com ([fe80::f1:ff4b:90a4:695%14]) with mapi id 14.01.0289.001; Tue, 25 Oct 2011 14:34:23 -0600 X-Originating-IP: [158.188.95.12] Content-language: en-US Thread-Topic: Guile 1.8 Garbage Collection Question Thread-Index: AcyTVWq2ojPqdoNQSzSK7EYaLvUVuA== Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.4.6813, 1.0.211, 0.0.0000 definitions=2011-10-25_07:2011-10-25, 2011-10-25, 1970-01-01 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.31.106.12 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8904 Archived-At: --Boundary_(ID_ThVbqZXy1xK9rvCClestnA) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT I have built Guile 1.8.8.2 on MinGW. I have wrapped some gtkwave code with Guile and have a memory issue. The following code apparently never frees 's', but I am not sure why. SCM_DEFINE (libguile_fst_writer_emit_value, "libguile-fst-writer-emit-value", 3,0,0, (SCM scm_ctx, SCM scm_fsthandle, SCM scm_val), "Write a change on fstHandle") { // Storage for temporary string char* s = NULL; scm_dynwind_begin (0); scm_dynwind_unwind_handler (free, s, SCM_F_WIND_EXPLICITLY); s = scm_to_locale_string (scm_val); fstWriterEmitValueChange(SCM_TO_CTX (scm_ctx), SCM_TO_FSTHANDLE (scm_fsthandle), s_buf); scm_dynwind_end(); return SCM_UNSPECIFIED; } The code is called from Scheme land in the following loop: (let loop ((n 0)) (if (eq? n 10000000) #t (begin ;; Emit some changes on the signal (fst-emit-value ctx s (number->string (modulo n 2))) (fst-emit-value ctx s1 (number->string (modulo (1+ n) 2))) (fst-emit-time-change ctx n) (loop (1+ n)) ))) It seems to me that the garbage collector never gets a chance to run, so how do I make sure that the gc gets a turn? If I define my function like the following, the leak disappears, but it's a less desirable solution: SCM_DEFINE (libguile_fst_writer_emit_value, "libguile-fst-writer-emit-value", 3,0,0, (SCM scm_ctx, SCM scm_fsthandle, SCM scm_val), "Write a change on fstHandle") { // Storage for temporary string char s_buf [1024]; scm_to_locale_stringbuf (scm_val, s_buf, 1024); s = scm_to_locale_string (scm_val); fstWriterEmitValueChange(SCM_TO_CTX (scm_ctx), SCM_TO_FSTHANDLE (scm_fsthandle), s_buf); return SCM_UNSPECIFIED; } Any suggestion? Thanks, Brad --Boundary_(ID_ThVbqZXy1xK9rvCClestnA) Content-type: text/html; charset=us-ascii Content-transfer-encoding: quoted-printable

I have built Guile 1.8.8.2 on MinGW.

 

I have wrapped some gtkwave code with Guile and have= a memory issue. The following code apparently never frees ‘s’,= but I am not sure why.

 

SCM_DEFINE (libguile_fst_writer_emit_value, "li= bguile-fst-writer-emit-value",

        &nbs= p;           3,0,0,=

        &nbs= p;           (SCM scm_ctx, SCM= scm_fsthandle, SCM scm_val),

        &nbs= p;           "Write = a change on fstHandle")

{

  // Storage for temporary string

  char* s =3D NULL;

  scm_dynwind_begin (0);

  scm_dynwind_unwind_handler (free, s, SCM_F_WI= ND_EXPLICITLY);

 

  s =3D scm_to_locale_string (scm_val);

 

  fstWriterEmitValueChange(SCM_TO_CTX (scm_ctx)= ,

        &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;    SCM_TO_FSTHANDLE (scm_fsthandle),

        &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;    s_buf);

 

  scm_dynwind_end();

 

  return SCM_UNSPECIFIED;

}

 

The code is called from Scheme land in the following= loop:

 

(let loop ((n 0))

  (if (eq? n 10000000) #t

      (begin

 

        &nbs= p;       ;; Emit some changes on the signal

        &nbs= p;       (fst-emit-value ctx s (number->st= ring (modulo n 2)))

        &nbs= p;       (fst-emit-value ctx s1 (number->s= tring (modulo (1+ n) 2)))

        &nbs= p;       (fst-emit-time-change ctx n)

 

        &nbs= p;       (loop (1+ n))

        &nbs= p;       )))

 

It seems to me that the garbage collector never gets= a chance to run, so how do I make sure that the gc gets a turn?

 

If I define my function like the following, the leak= disappears, but it’s a less desirable solution:

 

SCM_DEFINE (libguile_fst_writer_emit_value, "li= bguile-fst-writer-emit-value",

        &nbs= p;           3,0,0,=

        &nbs= p;           (SCM scm_ctx, SCM= scm_fsthandle, SCM scm_val),

        &nbs= p;           "Write = a change on fstHandle")

{

  // Storage for temporary string

  char s_buf [1024];

  scm_to_locale_stringbuf (scm_val, s_buf, 1024= );

  s =3D scm_to_locale_string (scm_val);

 

  fstWriterEmitValueChange(SCM_TO_CTX (scm_ctx)= ,

        &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;    SCM_TO_FSTHANDLE (scm_fsthandle),

        &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;    s_buf);

 

  return SCM_UNSPECIFIED;

}

 

Any suggestion?

 

Thanks,

Brad

--Boundary_(ID_ThVbqZXy1xK9rvCClestnA)--