From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mike Gran Newsgroups: gmane.lisp.guile.user Subject: Re: Proper way of making a single-pointer smob Date: Wed, 29 May 2013 07:02:33 -0700 (PDT) Message-ID: <1369836153.73399.YahooMailNeo@web120406.mail.ne1.yahoo.com> References: Reply-To: Mike Gran NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1369836179 20567 80.91.229.3 (29 May 2013 14:02:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 29 May 2013 14:02:59 +0000 (UTC) To: Sun Yijiang , "guile-user@gnu.org" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed May 29 16:02:57 2013 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Uhgxo-0008JD-GO for guile-user@m.gmane.org; Wed, 29 May 2013 16:02:52 +0200 Original-Received: from localhost ([::1]:54649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uhgxn-00075P-V6 for guile-user@m.gmane.org; Wed, 29 May 2013 10:02:51 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:40457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uhgxb-00074c-Gl for guile-user@gnu.org; Wed, 29 May 2013 10:02:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhgxW-0002Ln-N4 for guile-user@gnu.org; Wed, 29 May 2013 10:02:39 -0400 Original-Received: from nm35.bullet.mail.ne1.yahoo.com ([98.138.229.28]:23928) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhgxW-0002LZ-CD for guile-user@gnu.org; Wed, 29 May 2013 10:02:34 -0400 Original-Received: from [98.138.90.56] by nm35.bullet.mail.ne1.yahoo.com with NNFMP; 29 May 2013 14:02:33 -0000 Original-Received: from [98.138.89.199] by tm9.bullet.mail.ne1.yahoo.com with NNFMP; 29 May 2013 14:02:33 -0000 Original-Received: from [127.0.0.1] by omp1057.mail.ne1.yahoo.com with NNFMP; 29 May 2013 14:02:33 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 277636.36971.bm@omp1057.mail.ne1.yahoo.com Original-Received: (qmail 93141 invoked by uid 60001); 29 May 2013 14:02:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1369836153; bh=asRCsnYarcDS+ujuf8MzAlIw9lf5nDQnAbuM6g4Oweo=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=Ubf1h76X5oNvvifTDjKpM1r+xxMYol5xofv8ywud3pRj0IKhCyMpYt1IMdq8Gl9ivw4q+MGa3ud4V3WmQUh49gVG7I2Ju/ufrZIMl7uvKaQUSMPN52sxZmnAQh9ZZoGl3kyY8pjrRr/gjaGxtNw/abNkB9uHw+irg3AVGiDFmHE= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=Q3iClVCtfgTIw5G6myXdbxGWKeUMWiKo/++AUgYOdJJQC6/VrKHtLTyAbP9s4LNZSletHxB4Jjd36eaR7WH5VhbZRK2tx9sz1uh62BMXX9VNOh5sajffdRG0rRnly3H6QPHazg1wFdLOi3zE9shzkHMtUSYOtQ2BE9Noo3EjJfM=; X-YMail-OSG: c3mjrAIVM1m1.uY0llXjXj2K85DGkOc_3cLSLAwgRk6Wjbw 36njJf88eiZeuUsy3sTzDk.4ZPsx13JH8dv0vyuwPcbPOK.XHMJ1lQz3O_Jn xk5md6zziEuNKeldab0smK_dHoRHSag6oPNW1cVdC51o5FGry8yzQQvE90ex v9CPWCfamaWHYtabMGQ0Kqk43mMhRheEIPZAzfFV4noLse7RUW9uAqbKYpKf XXXdZw23Dv_gwELWYDk71Swva3QdK5RXwEs20LqkxhehfyANfk0XawZE3F3r fIWzUpRFpQ06XmWj3ylAuHhejMo2eRhJ6QofuA5DdwvV9goqXT7xhz1mGXc_ fB2wJUsMzsxpT5cOkGzPtt_gkVw84qA5eGKgPeBqLdy2DESGCPAFwfXu_QMs TUDUMH_3pPvRnQ0ONRqESt9xEW9huyPf4BkJeQRwAsG__dB2R6L8f0FkznP6 ktztZ.gWCPN7IeAFqv9_e8wYoU305ihHj93hy3zzn48quef9HWbWoFzUv9X. VVTCO9ZKHaBwYYeAdy7IXYsDlNalmTxynwqY.7Rgj2nt3uGHmuhy2c0Xvs17 R Original-Received: from [71.130.215.60] by web120406.mail.ne1.yahoo.com via HTTP; Wed, 29 May 2013 07:02:33 PDT X-Rocket-MIMEInfo: 002.001, PkhpIGd1eXMsCgoKPkknbSB1c2luZyBhIHZlcnkgc2ltcGxlIHNtb2Igd2hpY2ggb25seSBjYXJyaWVzIGEgcG9pbnRlciBpbiB0aGUKPmltbWVkaWF0ZSB3b3JkLsKgIEl0IHdvcmtzIGZpbmUsIGJ1dCB3aGF0IHdvcnJpZXMgbWUgaXMgdGhhdCB0aGUgZnJlZQo.ZnVuY3Rpb24gc2VlbXMgbmV2ZXIgY2FsbGVkLsKgwqDCoEFtIEkgZG9pbmcgYW55dGhpbmcgd3Jvbmc_wqAgV2hhdCdzIHRoZQo.c3RhbmRhcmQgd2F5IG9mIG1ha2luZyBzdWNoIGtpbmQgb2Ygc21vYj8KCgpXaGF0IHlvdSBhcmUgZG9pbmcgaXMBMAEBAQE- X-Mailer: YahooMailWebService/0.8.144.546 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-Received-From: 98.138.229.28 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:10378 Archived-At: >Hi guys,=0A=0A=0A>I'm using a very simple smob which only carries a pointe= r in the=0A>immediate word.=A0 It works fine, but what worries me is that t= he free=0A>function seems never called.=A0=A0=A0Am I doing anything wrong?= =A0 What's the=0A>standard way of making such kind of smob?=0A=0A=0AWhat yo= u are doing is mostly right, except for this.=0A=0A=0A> model_smob_t =3D sc= m_make_smob_type("model", 0);=A0 // shall I use zero here?=0A=0AYour "0" sh= ould be sizeof(MyModel*)=0A=0ABut that's not the problem.=0A=0AThe problem = is either=0A1. You still have a pointer to the smob somewhere.=A0 You need = to make=0A=A0sure that there are no pointers anywhere to the smob.=0A2. The= garbage collector isn't being run.=A0 Maybe you never allocate=0Aenough me= mory to cause the gc to run.=A0 You can fix this by adding=0Aa "scm_gc()" c= all just before you program exits to force a garbage=0Acollection.=0A3. Som= e versions of Guile have a bug where the last smob defined=0Ain your progra= m is never freed, even if you've cleared out the=0Apointers and called scm_= gc.=0A=0A-Mike