source: project/wiki/man/5/Module (chicken gc) @ 34902

Last change on this file since 34902 was 34902, checked in by sjamaan, 4 years ago

man/5: Move force-finalizer from TODO to Module (chicken gc)

File size: 2.5 KB
Line 
1[[tags: manual]]
2[[toc:]]
3
4== Module (chicken gc)
5
6This module provides some control over the garbage collector.
7
8=== gc
9
10<procedure>(gc [FLAG])</procedure>
11
12Invokes a garbage-collection and returns the number of free bytes in the heap.
13The flag specifies whether a minor ({{#f}}) or major ({{#t}}) GC is to be
14triggered. If no argument is given, {{#t}} is assumed. An explicit {{#t}}
15argument will cause all pending finalizers to be executed.
16
17=== current-gc-milliseconds
18
19<procedure>(current-gc-milliseconds)</procedure>
20
21Returns the number of milliseconds spent in major garbage collections since
22the last call of {{current-gc-milliseconds}} and returns an exact
23integer.
24
25=== memory-statistics
26
27<procedure>(memory-statistics)</procedure>
28
29Performs a major garbage collection and returns a three element vector
30containing the total heap size in bytes, the number of bytes currently
31used and the size of the nursery (the first heap generation). Note
32that the actual heap is actually twice the size given in the heap size,
33because CHICKEN uses a copying semi-space collector.
34
35
36=== set-finalizer!
37
38<procedure>(set-finalizer! X PROC)</procedure>
39
40Registers a procedure of one argument {{PROC}}, that will be
41called as soon as the non-immediate data object {{X}} is about to
42be garbage-collected (with that object as its argument). Note that
43the finalizer will '''not''' be called while interrupts are disabled.
44This procedure returns {{X}}.
45
46Finalizers are invoked asynchronously, in the thread that happens
47to be currently running. Finalizers for data that has become garbage
48are called on normal program exit. Finalizers are not run on
49abnormal program exit. A normal program exit does not run finalizers
50that are still reachable from global data.
51
52Multiple finalizers can be registered for the same object. The order
53in which the finalizers run is undefined. Execution of finalizers
54may be nested.
55
56
57=== force-finalizers
58
59<parameter>(force-finalizers)</parameter>
60
61If true, force and execute all pending finalizers before exiting the
62program (either explicitly by {{exit}} or implicitly when the last
63toplevel expression has been executed). Default is {{#t}}.
64
65
66=== set-gc-report!
67
68<procedure>(set-gc-report! FLAG)</procedure>
69
70Print statistics after every GC, depending on {{FLAG}}. A value of
71{{#t}} shows statistics after every major GC. A true value different
72from {{#t}} shows statistics after every minor GC. {{#f}}
73switches statistics off.
74
75
76---
77Previous: [[Module (chicken format)]]
78
79Next: [[Module (chicken io)]]
Note: See TracBrowser for help on using the repository browser.