[Top][All Lists]

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

bug#20907: [PATCH] Manual bug for scm_gc_protect_object

From: Mike Gran
Subject: bug#20907: [PATCH] Manual bug for scm_gc_protect_object
Date: Wed, 2 Sep 2015 15:36:13 +0000 (UTC)

> On Wednesday, September 2, 2015 5:09 AM, Ludovic Courtès <address@hidden> 
> wrote:

> I think the manual is correct: global C variables were *not* scanned by
> the GC.  As an example, see ‘scm_sys_protects’ in 1.8: It’s a global
> array that was explicitly scanned by the GC, because that’s basically
> the only mechanism to add new GC root:
>   while (j--)
>     scm_gc_mark (scm_sys_protects[j]);
> The 1.8 manual reads:
>      Other references to 'SCM' objects, such as global variables of type
>   'SCM' or other random data structures in the heap that contain fields 
> of
>   type 'SCM', can be made visible to the garbage collector by calling 
> the
>   functions 'scm_gc_protect' or 'scm_permanent_object'.  You 
> normally use
>   these funtions for long lived objects such as a hash table that is
>   stored in a global variable.  For temporary references in local
>   variables or function arguments, using these functions would be too
>   expensive.

For what it is worth, the effect that I was seeing that made me
question the documentation can be demonstrated by the attached program,
where two 100MB Guile strings are stored in a C globals: one protected
and one not. 

In 1.8, a GC operation reduces memory from 200MB to 100MB, which I
assume is freeing the memory from the unprotected string.

In 2.0, the heap size always stays at 200MB.

The output of the program for Guile 1.8.8 and Guile 2.0.9 is attached.


Attachment: main.c
Description: Text Data

Attachment: out18.txt
Description: Text document

Attachment: out20.txt
Description: Text document

reply via email to

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