emacs.d/clones/scheme/docs.racket-lang.org/reference/garbagecollection.html
2022-09-30 11:00:09 +02:00

101 lines
No EOL
32 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=0.8"/><title>16.4&nbsp;Garbage Collection</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="extras.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9658;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">The Racket Reference</a></td></tr></table></div><div class="tocviewsublisttop" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="model.html" class="tocviewlink" data-pltdoc="x">Language Model</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="notation.html" class="tocviewlink" data-pltdoc="x">Notation for Documentation</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="syntax.html" class="tocviewlink" data-pltdoc="x">Syntactic Forms</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="data.html" class="tocviewlink" data-pltdoc="x">Datatypes</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="structures.html" class="tocviewlink" data-pltdoc="x">Structures</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="mzlib_class.html" class="tocviewlink" data-pltdoc="x">Classes and Objects</a></td></tr><tr><td align="right">7&nbsp;</td><td><a href="mzlib_unit.html" class="tocviewlink" data-pltdoc="x">Units</a></td></tr><tr><td align="right">8&nbsp;</td><td><a href="contracts.html" class="tocviewlink" data-pltdoc="x">Contracts</a></td></tr><tr><td align="right">9&nbsp;</td><td><a href="match.html" class="tocviewlink" data-pltdoc="x">Pattern Matching</a></td></tr><tr><td align="right">10&nbsp;</td><td><a href="control.html" class="tocviewlink" data-pltdoc="x">Control Flow</a></td></tr><tr><td align="right">11&nbsp;</td><td><a href="concurrency.html" class="tocviewlink" data-pltdoc="x">Concurrency and Parallelism</a></td></tr><tr><td align="right">12&nbsp;</td><td><a href="Macros.html" class="tocviewlink" data-pltdoc="x">Macros</a></td></tr><tr><td align="right">13&nbsp;</td><td><a href="input-and-output.html" class="tocviewlink" data-pltdoc="x">Input and Output</a></td></tr><tr><td align="right">14&nbsp;</td><td><a href="security.html" class="tocviewlink" data-pltdoc="x">Reflection and Security</a></td></tr><tr><td align="right">15&nbsp;</td><td><a href="os.html" class="tocviewlink" data-pltdoc="x">Operating System</a></td></tr><tr><td align="right">16&nbsp;</td><td><a href="memory.html" class="tocviewselflink" data-pltdoc="x">Memory Management</a></td></tr><tr><td align="right">17&nbsp;</td><td><a href="unsafe.html" class="tocviewlink" data-pltdoc="x">Unsafe Operations</a></td></tr><tr><td align="right">18&nbsp;</td><td><a href="running.html" class="tocviewlink" data-pltdoc="x">Running Racket</a></td></tr><tr><td align="right"></td><td><a href="doc-bibliography.html" class="tocviewlink" data-pltdoc="x">Bibliography</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_1&quot;);">&#9660;</a></td><td>16&nbsp;</td><td><a href="memory.html" class="tocviewlink" data-pltdoc="x">Memory Management</a></td></tr></table><div class="tocviewsublistbottom" style="display: block;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">16.1&nbsp;</td><td><a href="weakbox.html" class="tocviewlink" data-pltdoc="x">Weak Boxes</a></td></tr><tr><td align="right">16.2&nbsp;</td><td><a href="ephemerons.html" class="tocviewlink" data-pltdoc="x">Ephemerons</a></td></tr><tr><td align="right">16.3&nbsp;</td><td><a href="willexecutor.html" class="tocviewlink" data-pltdoc="x">Wills and Executors</a></td></tr><tr><td align="right">16.4&nbsp;</td><td><a href="garbagecollection.html" class="tocviewselflink" data-pltdoc="x">Garbage Collection</a></td></tr><tr><td align="right">16.5&nbsp;</td><td><a href="phantom-bytes.html" class="tocviewlink" data-pltdoc="x">Phantom Byte Strings</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><a href="garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._collect-garbage%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">collect-<wbr></wbr>garbage</span></span></a></td></tr><tr><td><a href="garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._current-memory-use%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">current-<wbr></wbr>memory-<wbr></wbr>use</span></span></a></td></tr><tr><td><a href="garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._dump-memory-stats%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">dump-<wbr></wbr>memory-<wbr></wbr>stats</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" id="searchbox" type="text" tabindex="1" placeholder="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;8.6&quot;, &quot;../&quot;);"/></form>&nbsp;&nbsp;<a href="https://docs.racket-lang.org/index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;8.6&quot;);">top</a><span class="tocsettoggle">&nbsp;&nbsp;<a href="javascript:void(0);" title="show/hide table of contents" onclick="TocsetToggle();">contents</a></span></span><span class="navright">&nbsp;&nbsp;<a href="willexecutor.html" title="backward to &quot;16.3 Wills and Executors&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="memory.html" title="up to &quot;16 Memory Management&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="phantom-bytes.html" title="forward to &quot;16.5 Phantom Byte Strings&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div><h4 x-source-module="(lib &quot;scribblings/reference/reference.scrbl&quot;)" x-source-pkg="racket-doc" x-part-tag="&quot;garbagecollection&quot;">16.4<tt>&nbsp;</tt><a name="(part._garbagecollection)"></a>Garbage Collection</h4><p>Set the <a name="(idx._(gentag._448._(lib._scribblings/reference/reference..scrbl)))"></a><span class="stt">PLTDISABLEGC</span> environment variable (to any
value) before Racket starts to disable <a href="eval-model.html#%28tech._garbage._collection%29" class="techoutside" data-pltdoc="x"><span class="techinside">garbage collection</span></a>. Set
the <a name="(idx._(gentag._449._(lib._scribblings/reference/reference..scrbl)))"></a><span class="stt">PLT_INCREMENTAL_GC</span> environment variable
to a value that starts with <span class="RktInBG"><span class="hspace"></span><span class="RktIn">1</span><span class="hspace"></span></span>, <span class="RktInBG"><span class="hspace"></span><span class="RktIn">y</span><span class="hspace"></span></span>, or <span class="RktInBG"><span class="hspace"></span><span class="RktIn">Y</span><span class="hspace"></span></span> to
request incremental mode at all times, but calling
<span class="RktPn">(</span><span class="RktSym"><a href="garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._collect-garbage%29%29" class="RktValLink" data-pltdoc="x">collect-garbage</a></span><span class="stt"> </span><span class="RktVal">'</span><span class="RktVal">incremental</span><span class="RktPn">)</span> in a program with a periodic
task is generally a better mechanism for requesting incremental mode.
Set the <a name="(idx._(gentag._450._(lib._scribblings/reference/reference..scrbl)))"></a><span class="stt">PLT_INCREMENTAL_GC</span> environment variable
to a value that starts with <span class="RktInBG"><span class="hspace"></span><span class="RktIn">0</span><span class="hspace"></span></span>, <span class="RktInBG"><span class="hspace"></span><span class="RktIn">n</span><span class="hspace"></span></span>, or <span class="RktInBG"><span class="hspace"></span><span class="RktIn">N</span><span class="hspace"></span></span> to
disable incremental-mode requests.</p><p>Each garbage collection logs a message (see <a href="logging.html" data-pltdoc="x">Logging</a>) at the
<span class="RktVal">'</span><span class="RktVal">debug</span> level with topic <span class="RktVal">'</span><span class="RktVal">GC</span>. In the <a href="implementations.html#%28tech._c%29" class="techoutside" data-pltdoc="x"><span class="techinside">CS</span></a> and <a href="implementations.html#%28tech._3m%29" class="techoutside" data-pltdoc="x"><span class="techinside">3m</span></a>
implementations of Racket, &ldquo;major&rdquo; collections are also logged at the
<span class="RktVal">'</span><span class="RktVal">debug</span> level with the topic <span class="RktVal">'</span><span class="RktVal">GC:major</span>. In the <a href="implementations.html#%28tech._c%29" class="techoutside" data-pltdoc="x"><span class="techinside">CS</span></a>
and <a href="implementations.html#%28tech._3m%29" class="techoutside" data-pltdoc="x"><span class="techinside">3m</span></a> implementations of Racket, the data portion of the message is an
instance of a <a name="(idx._(gentag._451._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktSym">gc-info</span> <a href="structures.html#%28tech._prefab%29" class="techoutside" data-pltdoc="x"><span class="techinside">prefab</span></a> structure type
with 10 fields as follows, but future versions of Racket may use a
<span class="RktSym">gc-info</span> <a href="structures.html#%28tech._prefab%29" class="techoutside" data-pltdoc="x"><span class="techinside">prefab</span></a> structure with additional fields:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">gc-info</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mode</span><span class="hspace">&nbsp;</span><span class="RktSym">pre-amount</span><span class="hspace">&nbsp;</span><span class="RktSym">pre-admin-amount</span><span class="hspace">&nbsp;</span><span class="RktSym">code-amount</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym">post-amount</span><span class="hspace">&nbsp;</span><span class="RktSym">post-admin-amount</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym">start-process-time</span><span class="hspace">&nbsp;</span><span class="RktSym">end-process-time</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym">start-time</span><span class="hspace">&nbsp;</span><span class="RktSym">end-time</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr></table></blockquote><ul><li><p>The <span class="RktSym">mode</span> field is a symbol <span class="RktVal">'</span><span class="RktVal">major</span>,
<span class="RktVal">'</span><span class="RktVal">minor</span>, or <span class="RktVal">'</span><span class="RktVal">incremental</span>; <span class="RktVal">'</span><span class="RktVal">major</span>
indicates a collection that inspects all memory,
<span class="RktVal">'</span><span class="RktVal">minor</span> indicates collection that mostly inspects just
recent allocations, and <span class="RktVal">'</span><span class="RktVal">incremental</span> indicates a minor
collection that performs extra work toward the next major
collection.</p><p class="SHistory">Changed in version 6.3.0.7 of package <span class="stt">base</span>: Changed first field from a
boolean (<span class="RktVal">#t</span> for
<span class="RktVal">'</span><span class="RktVal">major</span>, <span class="RktVal">#f</span>
for <span class="RktVal">'</span><span class="RktVal">minor</span>) to a
mode symbol.</p></li><li><p>The <span class="RktSym">pre-amount</span> field reports place-local memory use
(i.e., not counting the memory use of child places) in bytes at
the time that the <a href="eval-model.html#%28tech._garbage._collection%29" class="techoutside" data-pltdoc="x"><span class="techinside">garbage collection</span></a> started. Additional
bytes registered via <span class="RktSym"><a href="phantom-bytes.html#%28def._%28%28quote._~23~25kernel%29._make-phantom-bytes%29%29" class="RktValLink" data-pltdoc="x">make-phantom-bytes</a></span> are included.</p></li><li><p>The <span class="RktSym">pre-admin-amount</span> is a larger number that includes
memory use for the garbage collector&rsquo;s overhead, such as space
on memory pages that are mapped but not currently used.</p></li><li><p>The <span class="RktSym">code-amount</span> field reports additional memory use
for generated native code (which is the same just before and
after a garbage collection, since it is released via
finalization).</p></li><li><p>The <span class="RktSym">post-amount</span> and <span class="RktSym">post-admin-amount</span> fields
correspond to <span class="RktSym">pre-amount</span> and
<span class="RktSym">pre-admin-amount</span>, but after garbage collection. In
typical configurations, the difference between
<span class="RktSym">post-amount</span> and <span class="RktSym">pre-amount</span> contributes to
<span class="RktSym">post-admin-amount</span>, since reclaimed pages tend to stay
in reserve with the expectation that they&rsquo;ll be needed again
(but the pages are released if multiple collections pass
without need for the pages).</p></li><li><p>The <span class="RktSym">start-process-time</span> and <span class="RktSym">end-process-time</span>
fields report processor time (in the sense of
<span class="RktSym"><a href="time.html#%28def._%28%28quote._~23~25kernel%29._current-process-milliseconds%29%29" class="RktValLink" data-pltdoc="x">current-process-milliseconds</a></span>) at the start and end of
garbage collection. The difference between the times is the
processor time consumed by collection.</p></li><li><p>The <span class="RktSym">start-time</span> and <span class="RktSym">end-time</span> fields report
real time (in the sense of
<span class="RktSym"><a href="time.html#%28def._%28%28quote._~23~25kernel%29._current-inexact-milliseconds%29%29" class="RktValLink" data-pltdoc="x">current-inexact-milliseconds</a></span>) at the start and end of
garbage collection. The difference between the times is the
real time consumed by garbage collection.</p></li></ul><p>The format of the logged message&rsquo;s text is subject to change.
Currently, after a prefix that indicates the <a href="places.html#%28tech._place%29" class="techoutside" data-pltdoc="x"><span class="techinside">place</span></a> and
collection mode, the text has the format</p><blockquote><p><span class="sroman">&#8249;<span style="font-style: italic">used</span>&#8250;</span><span class="stt">(</span><span class="sroman">&#8249;<span style="font-style: italic">admin</span>&#8250;</span><span class="stt">)[</span><span class="sroman">&#8249;<span style="font-style: italic">code</span>&#8250;</span><span class="stt">]; free </span><span class="sroman">&#8249;<span style="font-style: italic">reclaimed</span>&#8250;</span><span class="stt">(</span><span class="sroman">&#8249;<span style="font-style: italic">adjust</span>&#8250;</span><span class="stt">) </span><span class="sroman">&#8249;<span style="font-style: italic">elapsed</span>&#8250;</span><span class="stt"> @ </span><span class="sroman">&#8249;<span style="font-style: italic">timestamp</span>&#8250;</span></p><table cellspacing="0" cellpadding="0"><tr><td><p><span class="sroman">&#8249;<span style="font-style: italic">used</span>&#8250;</span></p></td><td><p><span class="hspace">&nbsp;</span></p></td><td><p>Collectable memory in use just prior to garbage collection</p></td></tr><tr><td><p><span class="sroman">&#8249;<span style="font-style: italic">admin</span>&#8250;</span></p></td><td><p><span class="hspace">&nbsp;</span></p></td><td><p>Additional memory used as to manage collectable memory</p></td></tr><tr><td><p><span class="sroman">&#8249;<span style="font-style: italic">code</span>&#8250;</span></p></td><td><p><span class="hspace">&nbsp;</span></p></td><td><p>Additional memory used for generated machine code</p></td></tr><tr><td><p><span class="sroman">&#8249;<span style="font-style: italic">reclaimed</span>&#8250;</span></p></td><td><p><span class="hspace">&nbsp;</span></p></td><td><p>Collectable memory reclaimed by garbage collection</p></td></tr><tr><td><p><span class="sroman">&#8249;<span style="font-style: italic">adjust</span>&#8250;</span></p></td><td><p><span class="hspace">&nbsp;</span></p></td><td><p>Negation of change to administrative memory minus <span class="sroman">&#8249;<span style="font-style: italic">reclaimed</span>&#8250;</span></p></td></tr><tr><td><p><span class="sroman">&#8249;<span style="font-style: italic">elapsed</span>&#8250;</span></p></td><td><p><span class="hspace">&nbsp;</span></p></td><td><p>Processor time used to perform garbage collection</p></td></tr><tr><td><p><span class="sroman">&#8249;<span style="font-style: italic">timestamp</span>&#8250;</span></p></td><td><p><span class="hspace">&nbsp;</span></p></td><td><p>Processor time since startup of garbage collection&rsquo;s start</p></td></tr></table></blockquote><p class="SHistory">Changed in version 6.3.0.7 of package <span class="stt">base</span>: Added <span class="stt">PLT_INCREMENTAL_GC</span>.<br/>Changed in version 7.6.0.9: Added major-collection logging for the topic <span class="RktVal">'</span><span class="RktVal">GC:major</span>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((quote._~23~25kernel)._collect-garbage))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._collect-garbage%29%29" class="RktValDef RktValLink" data-pltdoc="x">collect-garbage</a></span></span><span class="hspace">&nbsp;</span><span class="RktOpt">[</span><span class="RktVar">request</span><span class="RktOpt">]</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="void.html#%28def._%28%28quote._~23~25kernel%29._void~3f%29%29" class="RktValLink" data-pltdoc="x">void?</a></span></p></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">request</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">major</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">minor</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">incremental</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">major</span></td></tr></table></blockquote></div><div class="SIntrapara">Requests an immediate <a href="eval-model.html#%28tech._garbage._collection%29" class="techoutside" data-pltdoc="x"><span class="techinside">garbage collection</span></a> or requests a
garbage-collection mode, depending on <span class="RktVar">request</span>:</div></p><ul><li><p><span class="RktVal">'</span><span class="RktVal">major</span> &#8212;<wbr></wbr> Forces a &ldquo;major&rdquo; collection, which
inspects all memory. Some effectively unreachable data may
remain uncollected, because the collector cannot prove that it
is unreachable.</p><p>This mode of <span class="RktSym"><a href="garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._collect-garbage%29%29" class="RktValLink" data-pltdoc="x">collect-garbage</a></span> procedure provides some
control over the timing of collections, but garbage will
obviously be collected even if this procedure is never
called&#8212;<wbr></wbr>unless garbage collection is disabled by setting
<span class="stt">PLTDISABLEGC</span>.</p></li><li><p><span class="RktVal">'</span><span class="RktVal">minor</span> &#8212;<wbr></wbr> Requests a &ldquo;minor&rdquo; collection, which
mostly inspects only recent allocations. If minor collection is
not supported (e.g., when <span class="RktPn">(</span><span class="RktSym"><a href="runtime.html#%28def._%28%28quote._~23~25kernel%29._system-type%29%29" class="RktValLink" data-pltdoc="x">system-type</a></span><span class="stt"> </span><span class="RktVal">'</span><span class="RktVal">gc</span><span class="RktPn">)</span> returns
<span class="RktVal">'</span><span class="RktVal">cgc</span>) or if the next collection must be a major
collection, no collection is performed. More generally, minor collections
triggered by <span class="RktPn">(</span><span class="RktSym"><a href="garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._collect-garbage%29%29" class="RktValLink" data-pltdoc="x">collect-garbage</a></span><span class="stt"> </span><span class="RktVal">'</span><span class="RktVal">minor</span><span class="RktPn">)</span> do not cause
major collections any sooner than they would occur otherwise.</p></li><li><p><span class="RktVal">'</span><span class="RktVal">incremental</span> &#8212;<wbr></wbr> Does not request an immediate
collection, but requests extra effort going forward to avoid
major collections, even if it requires more work per minor
collection to incrementally perform the work of a major
collection. This incremental-mode request expires at the next
major collection.</p><p>The intent of incremental mode is to significantly reduce pause
times due to major collections, but incremental mode may imply
longer minor-collection times and higher memory use. Currently,
incremental mode is only meaningful for <a href="implementations.html#%28tech._c%29" class="techoutside" data-pltdoc="x"><span class="techinside">CS</span></a> and <a href="implementations.html#%28tech._3m%29" class="techoutside" data-pltdoc="x"><span class="techinside">3m</span></a>
Racket implementations; it has no effect in
other Racket implementations.</p><p>If the <span class="stt">PLT_INCREMENTAL_GC</span> environment variable&rsquo;s value
starts with <span class="RktInBG"><span class="hspace"></span><span class="RktIn">0</span><span class="hspace"></span></span>, <span class="RktInBG"><span class="hspace"></span><span class="RktIn">n</span><span class="hspace"></span></span>, or <span class="RktInBG"><span class="hspace"></span><span class="RktIn">N</span><span class="hspace"></span></span> on
start-up, then incremental-mode requests are ignored.</p></li></ul><p class="SHistory">Changed in version 6.3 of package <span class="stt">base</span>: Added the <span class="RktVar">request</span> argument.<br/>Changed in version 6.3.0.2: Added <span class="RktVal">'</span><span class="RktVal">incremental</span> mode.<br/>Changed in version 7.7.0.4: Added <span class="RktVal">'</span><span class="RktVal">incremental</span> effect
for Racket <a href="implementations.html#%28tech._c%29" class="techoutside" data-pltdoc="x"><span class="techinside">CS</span></a>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((quote._~23~25kernel)._current-memory-use))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._current-memory-use%29%29" class="RktValDef RktValLink" data-pltdoc="x">current-memory-use</a></span></span><span class="hspace">&nbsp;</span><span class="RktOpt">[</span><span class="RktVar">mode</span><span class="RktOpt">]</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._exact-nonnegative-integer~3f%29%29" class="RktValLink" data-pltdoc="x">exact-nonnegative-integer?</a></span></p></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">mode</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">cumulative</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="custodians.html#%28def._%28%28quote._~23~25kernel%29._custodian~3f%29%29" class="RktValLink" data-pltdoc="x">custodian?</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktVal">#f</span></td></tr></table></blockquote></div><div class="SIntrapara">Returns information about memory use:</div></p><ul><li><p>If <span class="RktVar">mode</span> is <span class="RktVal">#f</span> (the default), the result is an
estimate of the number of bytes reachable from any custodian.</p></li><li><p>If <span class="RktVar">mode</span> is <span class="RktVal">'</span><span class="RktVal">cumulative</span>, returns an estimate
of the total number of bytes allocated since start up,
including bytes that have since been reclaimed by garbage
collection.</p></li><li><p>If <span class="RktVar">mode</span> is a custodian, returns an estimate of the
number of bytes of memory occupied by reachable data from
<span class="RktVar">mode</span>. This estimate is calculated by the last garbage
collection, and can be 0 if none occurred (or if none occurred
since the given custodian was created). The
<span class="RktSym"><a href="garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._current-memory-use%29%29" class="RktValLink" data-pltdoc="x">current-memory-use</a></span> function does <span style="font-style: italic">not</span> perform
a collection by itself; doing one before the call will
generally decrease the result (or increase it from 0 if no
collections happened yet).</p><p>When Racket is compiled without support for memory accounting,
the estimate is the same as when <span class="RktVar">mode</span> is <span class="RktVal">#f</span>
(i.e., all memory) for any individual custodian. See also
<span class="RktSym"><a href="custodians.html#%28def._%28%28quote._~23~25kernel%29._custodian-memory-accounting-available~3f%29%29" class="RktValLink" data-pltdoc="x">custodian-memory-accounting-available?</a></span>.</p></li></ul><p>See also <span class="RktSym"><a href="runtime.html#%28def._%28%28quote._~23~25kernel%29._vector-set-performance-stats%21%29%29" class="RktValLink" data-pltdoc="x">vector-set-performance-stats!</a></span>.</p><p class="SHistory">Changed in version 6.6.0.3 of package <span class="stt">base</span>: Added <span class="RktVal">'</span><span class="RktVal">cumulative</span> mode.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((quote._~23~25kernel)._dump-memory-stats))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="garbagecollection.html#%28def._%28%28quote._~23~25kernel%29._dump-memory-stats%29%29" class="RktValDef RktValLink" data-pltdoc="x">dump-memory-stats</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">v</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="data-structure-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%29%29" class="RktStxLink" data-pltdoc="x">any</a></span></p></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">v</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Dumps information about memory usage to the low-level error port
or console.</div></p><p>Various combinations of <span class="RktVar">v</span> arguments can control the
information in a dump. The information that is available depends on
your Racket build; check the end of a dump from a particular build to
see if it offers additional information; otherwise, all <span class="RktVar">v</span>s are
ignored.</p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" id="searchbox" type="text" tabindex="1" placeholder="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;8.6&quot;, &quot;../&quot;);"/></form>&nbsp;&nbsp;<a href="https://docs.racket-lang.org/index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;8.6&quot;);">top</a><span class="tocsettoggle">&nbsp;&nbsp;<a href="javascript:void(0);" title="show/hide table of contents" onclick="TocsetToggle();">contents</a></span></span><span class="navright">&nbsp;&nbsp;<a href="willexecutor.html" title="backward to &quot;16.3 Wills and Executors&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="memory.html" title="up to &quot;16 Memory Management&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="phantom-bytes.html" title="forward to &quot;16.5 Phantom Byte Strings&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>