MLton

Executables produced by MLton take command line arguments that control the runtime system. These arguments are optional, and occur before the executable’s usual arguments. To use these options, the first argument to the executable must be @MLton. The optional arguments then follow, must be terminated by --, and are followed by any arguments to the program. The optional arguments are not made available to the SML program via CommandLine.arguments. For example, a valid call to hello-world is:

hello-world @MLton gc-summary fixed-heap 10k -- a b c

In the above example, CommandLine.arguments () = ["a", "b", "c"].

It is allowed to have a sequence of @MLton arguments, as in:

hello-world @MLton gc-summary -- @MLton fixed-heap 10k -- a b c

Run-time options can also control MLton, as in

mlton @MLton fixed-heap 0.5g -- foo.sml

Options

  • fixed-heap x{k|K|m|M|g|G}

    Use a fixed size heap of size x, where x is a real number and the trailing letter indicates its units.

    k or K

    1024

    m or M

    1,048,576

    g or G

    1,073,741,824

    A value of 0 means to use almost all the RAM present on the machine.

    The heap size used by fixed-heap 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.

  • gc-messages

    Print a message at the start and end of every garbage collection.

  • gc-summary

    Print a summary of garbage collection statistics upon program termination to standard error.

  • gc-summary-file file

    Print a summary of garbage collection statistics upon program termination to the file specified by file.

  • load-world world

    Restart the computation with the file specified by world, which must have been created by a call to MLton.World.save by the same executable. See MLtonWorld.

  • max-heap x{k|K|m|M|g|G}

    Run the computation with an automatically resized heap that is never larger than x, where x is a real number and the trailing letter indicates the units as with fixed-heap. The heap size for max-heap is accounted for as with fixed-heap.

  • may-page-heap {false|true}

    Enable paging the heap to disk when unable to grow the heap to a desired size.

  • no-load-world

    Disable load-world. This can be used as an argument to the compiler via -runtime no-load-world 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.

  • ram-slop x

    Multiply x by the amount of RAM on the machine to obtain what the runtime views as the amount of RAM it can use. Typically x is less than 1, and is used to account for space used by other programs running on the same machine.

  • stop

    Causes the runtime to stop processing @MLton arguments once the next -- is reached. This can be used as an argument to the compiler via -runtime stop to create executables that don’t process any @MLton arguments.