2 |
@node Memory Management |
@node Memory Management |
3 |
@chapter Memory Management and Garbage Collection |
@chapter Memory Management and Garbage Collection |
4 |
|
|
5 |
|
Guile uses a @emph{garbage collector} to manage most of its objects. |
6 |
|
This means that the memory used to store a Scheme string, say, is |
7 |
|
automatically reclaimed when no one is using this string any longer. |
8 |
|
This can work because Guile knows enough about its objects at run-time |
9 |
|
to be able to trace all references between them. Thus, it can find |
10 |
|
all 'life' objects (objects that are still in use) by starting from a |
11 |
|
known set of 'root' objects and following the links that these objects |
12 |
|
have to other objects, and so on. The objects that are not reached by |
13 |
|
this recursive process can be considered 'dead' and their memory can |
14 |
|
be used for new objects. |
15 |
|
|
16 |
|
When you are programming in Scheme, you don't need to worry about the |
17 |
|
garbage collector. When programming in C, there are a few rules that |
18 |
|
you must follow so that the garbage collector can do its job. |
19 |
|
|
20 |
@menu |
@menu |
21 |
* Garbage Collection:: |
* Garbage Collection:: |
22 |
* Memory Blocks:: |
* Memory Blocks:: |