Debian Codegraph @

doc/guide/src/RunTimeOptions.adoc

raw
1 = RunTimeOptions
2
3 Executables produced by MLton take command line arguments that control
4 the runtime system. These arguments are optional, and occur before
5 the executable's usual arguments. To use these options, the first
6 argument to the executable must be `@MLton`. The optional arguments
7 then follow, must be terminated by `--`, and are followed by any
8 arguments to the program. The optional arguments are _not_ made
9 available to the SML program via `CommandLine.arguments`. For
10 example, a valid call to `hello-world` is:
11
12 ----
13 hello-world @MLton gc-summary fixed-heap 10k -- a b c
14 ----
15
16 In the above example,
17 `CommandLine.arguments () = ["a", "b", "c"]`.
18
19 It is allowed to have a sequence of `@MLton` arguments, as in:
20
21 ----
22 hello-world @MLton gc-summary -- @MLton fixed-heap 10k -- a b c
23 ----
24
25 Run-time options can also control MLton, as in
26
27 ----
28 mlton @MLton fixed-heap 0.5g -- foo.sml
29 ----
30
31
32 == Options
33
34 * ``fixed-heap __x__{k|K|m|M|g|G}``
35 +
36 Use a fixed size heap of size _x_, where _x_ is a real number and the
37 trailing letter indicates its units.
38 +
39 [cols="^25%,<75%"]
40 |===
41 | `k` or `K` | 1024
42 | `m` or `M` | 1,048,576
43 | `g` or `G` | 1,073,741,824
44 |===
45 +
46 A value of `0` means to use almost all the RAM present on the machine.
47 +
48 The heap size used by `fixed-heap` includes all memory allocated by
49 SML code, including memory for the stack (or stacks, if there are
50 multiple threads). It does not, however, include any memory used for
51 code itself or memory used by C globals, the C stack, or malloc.
52
53 * ``gc-messages``
54 +
55 Print a message at the start and end of every garbage collection.
56
57 * ``gc-summary``
58 +
59 Print a summary of garbage collection statistics upon program
60 termination to standard error.
61
62 * ``gc-summary-file __file__``
63 +
64 Print a summary of garbage collection statistics upon program
65 termination to the file specified by _file_.
66
67 * ``load-world __world__``
68 +
69 Restart the computation with the file specified by _world_, which must
70 have been created by a call to `MLton.World.save` by the same
71 executable. See <<MLtonWorld#>>.
72
73 * ``max-heap __x__{k|K|m|M|g|G}``
74 +
75 Run the computation with an automatically resized heap that is never
76 larger than _x_, where _x_ is a real number and the trailing letter
77 indicates the units as with `fixed-heap`. The heap size for
78 `max-heap` is accounted for as with `fixed-heap`.
79
80 * ``may-page-heap {false|true}``
81 +
82 Enable paging the heap to disk when unable to grow the heap to a
83 desired size.
84
85 * ``no-load-world``
86 +
87 Disable `load-world`. This can be used as an argument to the compiler
88 via `-runtime no-load-world` to create executables that will not load
89 a world. This may be useful to ensure that set-uid executables do not
90 load some strange world.
91
92 * ``ram-slop __x__``
93 +
94 Multiply _x_ by the amount of RAM on the machine to obtain what the
95 runtime views as the amount of RAM it can use. Typically _x_ is less
96 than 1, and is used to account for space used by other programs
97 running on the same machine.
98
99 * ``stop``
100 +
101 Causes the runtime to stop processing `@MLton` arguments once the next
102 `--` is reached. This can be used as an argument to the compiler via
103 `-runtime stop` to create executables that don't process any `@MLton`
104 arguments.