|OCAMLRUN(1)||General Commands Manual||OCAMLRUN(1)|
ocamlrun - The OCaml bytecode interpreter
ocamlrun [ options ] filename argument ...
The first non-option argument is taken to be the name of the file containing the executable bytecode. (That file is searched in the executable path as well as in the current directory.) The remaining arguments are passed to the OCaml program, in the string array Sys.argv. Element 0 of this array is the name of the bytecode executable file; elements 1 to n are the remaining arguments.
The following command-line options are recognized by ocamlrun(1).
- When the program aborts due to an uncaught exception, print a detailed "back trace" of the execution, showing where the exception was raised and which function calls were outstanding at this point. The back trace is printed only if the bytecode executable contains debugging information, i.e. was compiled and linked with the -g option to ocamlc(1) set. This option is equivalent to setting the b flag in the OCAMLRUNPARAM environment variable (see below).
- -I dir
- Search the directory dir for dynamically-loaded libraries, in addition to the standard search path.
- Print the names of the primitives known to this version of ocamlrun(1) and exit.
- Direct the memory manager to print verbose messages on standard error. This is equivalent to setting v=63 in the OCAMLRUNPARAM environment variable (see below).
- Print version string and exit.
- Print short version number and exit.
The following environment variable are also consulted:
- Additional directories to search for dynamically-loaded libraries.
- The directory containing the OCaml standard library. (If OCAMLLIB is not set, CAMLLIB will be used instead.) Used to locate the ld.conf configuration file for dynamic loading. If not set, default to the library directory specified when compiling OCaml.
- Set the runtime system options and garbage collection parameters. (If OCAMLRUNPARAM is not set, CAMLRUNPARAM will be used instead.) This variable must be a sequence of parameter specifications separated by commas. A parameter specification is a letter, optionally followed by an = sign, a decimal number (or a hexadecimal number prefixed by 0x), and an optional multiplier. If the letter is followed by anything else, the corresponding option is set to 1. Unknown letters are ignored. The options are documented below; the last six correspond to the fields of the control record documented in The OCaml user's manual, chapter "Standard Library", section "Gc".
- Trigger the printing of a stack backtrace when an uncaught exception aborts the program. This option takes no argument.
- Turn on debugging support for ocamlyacc-generated parsers. When this option is on, the pushdown automaton that executes the parsers prints a trace of its actions. This option takes no argument.
- Turn on randomization of all hash tables by default (see the Hashtbl module of the standard library). This option takes no argument.
- The initial size of the major heap (in words).
- a (allocation_policy)
- The policy used for allocating in the OCaml heap. Possible values are 0 for the next-fit policy, 1 for the first-fit policy, and 2 for the best-fit policy. The default is 2. See the Gc module documentation for details.
- s (minor_heap_size)
- The size of the minor heap (in words).
- i (major_heap_increment)
- The default size increment for the major heap (in words).
- o (space_overhead)
- The major GC speed setting.
- O (max_overhead)
- The heap compaction trigger setting.
- l (stack_limit)
- The limit (in words) of the stack size.
- M (custom_major_ratio)
- Target ratio of floating garbage to major heap size for out-of-heap memory held by custom values located in the major heap. The GC speed is adjusted to try to use this much memory for dead values that are not yet collected. Expressed as a percentage of major heap size. The default value keeps the out-of-heap floating garbage about the same size as the in-heap overhead. Note: this only applies to values allocated with caml_alloc_custom_mem (e.g. bigarrays). Default: 44.
- m (custom_minor_ratio)
- Bound on floating garbage for out-of-heap memory held by custom values in
the minor heap. A minor GC is triggered when this much memory is held by
custom values located in the minor heap. Expressed as a percentage of
minor heap size. Note: this only applies to values allocated with
caml_alloc_custom_mem (e.g. bigarrays).
- n (custom_minor_max_size)
- Maximum amount of out-of-heap memory for each custom value allocated in the minor heap. When a custom value is allocated on the minor heap and holds more than this many bytes, only this value is counted against custom_minor_ratio and the rest is directly counted against custom_major_ratio. Note: this only applies to values allocated with caml_alloc_custom_mem (e.g. bigarrays). Default: 8192 bytes.
- v (verbose)
- What GC messages to print to stderr. This is a sum of values selected from
0x001 Start and end of major GC cycle.
0x002 Minor collection and major GC slice.
0x004 Growing and shrinking of the heap.
0x008 Resizing of stacks and memory manager tables.
0x010 Heap compaction.
0x020 Change of GC parameters.
0x040 Computation of major GC slice size.
0x080 Calling of finalisation functions.
0x100 Startup messages (loading the bytecode executable file, resolving shared libraries).
0x200 Computation of compaction-triggering condition.
0x400 Output GC statistics at program exit, in the same format as Gc.print_stat.
The multiplier is k, M, or G, for multiplication by 2^10, 2^20, and 2^30 respectively.
If the option letter is not recognized, the whole parameter is ignored; if the equal sign or the number is missing, the value is taken as 1; if the multiplier is not recognized, it is ignored.
For example, on a 32-bit machine under bash, the command export OCAMLRUNPARAM='s=256k,v=1' tells a subsequent ocamlrun to set its initial minor heap size to 1 megabyte and to print a message at the start of each major GC cycle.
- If OCAMLRUNPARAM is not found in the environment, then CAMLRUNPARAM will be used instead. If CAMLRUNPARAM is also not found, then the default values will be used.
- List of directories searched to find the bytecode executable file.
The OCaml user's manual, chapter "Runtime system".