[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: |
Thu, 30 May 2013 00:10:28 -0700 (PDT) |
> Mike Gran <address@hidden> skribis:
>> 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.
> What is this? I’d be happy to read more details. :-)
To be more specific, if you want to make sure the GC frees every smob,
you should call scm_gc before the program ends.
But, if you place the scm_gc call inside of a function
designated by C's atexit() function, instead of, say, at the end of
main(), it may not free all the SMOBs. I never investigated why.
I assumed it was a race.
So, it is probably not really a Guile bug, but, rather, that calling
scm_gc from within atexit() is a bad idea.
The program below gives me the following output in Guile 2.0.9
Allocating #1
Allocating #2
Allocating #3
Allocating #4
Allocating #5
Allocating #6
Allocating #7
Allocating #8
Allocating #9
Allocating #10
Freeing #5
Freeing #6
Freeing #3
Freeing #4
Freeing #2
Freeing #1
gc at exit
Freeing #9
Freeing #7
Freeing #8
-Mike
tmp.cc
Description: Text Data