[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Proper way of making a single-pointer smob

From: Mike Gran
Subject: Re: Proper way of making a single-pointer smob
Date: Wed, 29 May 2013 07:02:33 -0700 (PDT)

>Hi guys,

>I'm using a very simple smob which only carries a pointer in the
>immediate word.  It works fine, but what worries me is that the free
>function seems never called.   Am I doing anything wrong?  What's the
>standard way of making such kind of smob?

What you are doing is mostly right, except for this.

> model_smob_t = scm_make_smob_type("model", 0);  // shall I use zero here?

Your "0" should be sizeof(MyModel*)

But that's not the problem.

The problem is either
1. You still have a pointer to the smob somewhere.  You need to make
 sure that there are no pointers anywhere to the smob.
2. The garbage collector isn't being run.  Maybe you never allocate
enough memory to cause the gc to run.  You can fix this by adding
a "scm_gc()" call just before you program exits to force a garbage
3. Some versions of Guile have a bug where the last smob defined
in your program is never freed, even if you've cleared out the
pointers and called scm_gc.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]