<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="AsciiDoc 8.6.10">
<title>RunTimeOptions</title>
<link rel="stylesheet" href="./asciidoc.css" type="text/css">
<link rel="stylesheet" href="./pygments.css" type="text/css">


<script type="text/javascript" src="./asciidoc.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
asciidoc.install();
/*]]>*/
</script>
<link rel="stylesheet" href="./mlton.css" type="text/css">
</head>
<body class="article">
<div id="banner">
<div id="banner-home">
<a href="./Home">MLton 20201002</a>
</div>
</div>
<div id="header">
<h1>RunTimeOptions</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p>Executables produced by MLton take command line arguments that control
the runtime system.  These arguments are optional, and occur before
the executable&#8217;s usual arguments.  To use these options, the first
argument to the executable must be <span class="monospaced">@MLton</span>.  The optional arguments
then follow, must be terminated by <span class="monospaced">--</span>, and are followed by any
arguments to the program.  The optional arguments are <em>not</em> made
available to the SML program via <span class="monospaced">CommandLine.arguments</span>.  For
example, a valid call to <span class="monospaced">hello-world</span> is:</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>hello-world @MLton gc-summary fixed-heap 10k -- a b c</pre>
</div></div>
<div class="paragraph"><p>In the above example,
<span class="monospaced">CommandLine.arguments () = ["a", "b", "c"]</span>.</p></div>
<div class="paragraph"><p>It is allowed to have a sequence of <span class="monospaced">@MLton</span> arguments, as in:</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>hello-world @MLton gc-summary -- @MLton fixed-heap 10k -- a b c</pre>
</div></div>
<div class="paragraph"><p>Run-time options can also control MLton, as in</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>mlton @MLton fixed-heap 0.5g -- foo.sml</pre>
</div></div>
</div>
</div>
<div class="sect1">
<h2 id="_options">Options</h2>
<div class="sectionbody">
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">fixed-heap <em>x</em>{k|K|m|M|g|G}</span>
</p>
<div class="paragraph"><p>Use a fixed size heap of size <em>x</em>, where <em>x</em> is a real number and the
trailing letter indicates its units.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<col style="width:25%;">
<col style="width:75%;">
<tbody>
<tr>
<td class="tableblock halign-center valign-top" ><p class="tableblock"><span class="monospaced">k</span> or <span class="monospaced">K</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1024</p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top" ><p class="tableblock"><span class="monospaced">m</span> or <span class="monospaced">M</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1,048,576</p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top" ><p class="tableblock"><span class="monospaced">g</span> or <span class="monospaced">G</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1,073,741,824</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>A value of <span class="monospaced">0</span> means to use almost all the RAM present on the machine.</p></div>
<div class="paragraph"><p>The heap size used by <span class="monospaced">fixed-heap</span> includes all memory allocated by
SML code, including memory for the stack (or stacks, if there are
multiple threads).  It does not, however, include any memory used for
code itself or memory used by C globals, the C stack, or malloc.</p></div>
</li>
<li>
<p>
<span class="monospaced">gc-messages</span>
</p>
<div class="paragraph"><p>Print a message at the start and end of every garbage collection.</p></div>
</li>
<li>
<p>
<span class="monospaced">gc-summary</span>
</p>
<div class="paragraph"><p>Print a summary of garbage collection statistics upon program
termination to standard error.</p></div>
</li>
<li>
<p>
<span class="monospaced">gc-summary-file <em>file</em></span>
</p>
<div class="paragraph"><p>Print a summary of garbage collection statistics upon program
termination to the file specified by <em>file</em>.</p></div>
</li>
<li>
<p>
<span class="monospaced">load-world <em>world</em></span>
</p>
<div class="paragraph"><p>Restart the computation with the file specified by <em>world</em>, which must
have been created by a call to <span class="monospaced">MLton.World.save</span> by the same
executable.  See <a href="MLtonWorld">MLtonWorld</a>.</p></div>
</li>
<li>
<p>
<span class="monospaced">max-heap <em>x</em>{k|K|m|M|g|G}</span>
</p>
<div class="paragraph"><p>Run the computation with an automatically resized heap that is never
larger than <em>x</em>, where <em>x</em> is a real number and the trailing letter
indicates the units as with <span class="monospaced">fixed-heap</span>.  The heap size for
<span class="monospaced">max-heap</span> is accounted for as with <span class="monospaced">fixed-heap</span>.</p></div>
</li>
<li>
<p>
<span class="monospaced">may-page-heap {false|true}</span>
</p>
<div class="paragraph"><p>Enable paging the heap to disk when unable to grow the heap to a
desired size.</p></div>
</li>
<li>
<p>
<span class="monospaced">no-load-world</span>
</p>
<div class="paragraph"><p>Disable <span class="monospaced">load-world</span>.  This can be used as an argument to the compiler
via <span class="monospaced">-runtime no-load-world</span> to create executables that will not load
a world.  This may be useful to ensure that set-uid executables do not
load some strange world.</p></div>
</li>
<li>
<p>
<span class="monospaced">ram-slop <em>x</em></span>
</p>
<div class="paragraph"><p>Multiply <em>x</em> by the amount of RAM on the machine to obtain what the
runtime views as the amount of RAM it can use.  Typically <em>x</em> is less
than 1, and is used to account for space used by other programs
running on the same machine.</p></div>
</li>
<li>
<p>
<span class="monospaced">stop</span>
</p>
<div class="paragraph"><p>Causes the runtime to stop processing <span class="monospaced">@MLton</span> arguments once the next
<span class="monospaced">--</span> is reached.  This can be used as an argument to the compiler via
<span class="monospaced">-runtime stop</span> to create executables that don&#8217;t process any <span class="monospaced">@MLton</span>
arguments.</p></div>
</li>
</ul></div>
</div>
</div>
</div>
<div id="footnotes"><hr></div>
<div id="footer">
<div id="footer-text">
</div>
<div id="footer-badges">
</div>
</div>
</body>
</html>
