OCAMLRUN(1)
π ocamlrun(1) β The OCaml Bytecode Interpreter π
Manual name, folded in near the top like a little name tag: General Commands Manual, bestie. π«Ά
πΈ NAME πΈ
ocamlrun β The OCaml bytecode interpreter.
β¨ SYNOPSIS β¨
ocamlrun [ options ] filename argument ...
π DESCRIPTION π
Okay so ocamlrun(1) is the command that executes bytecode files made by the linking phase of ocamlc(1). That's the whole vibe. π¦
The first non-option argument is taken as 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 get 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. β¨
In most cases, the bytecode executable files produced by the ocamlc(1) command are self-executable, and manage to launch the ocamlrun(1) command on themselves automatically. Iconic behavior, honestly. π
π OPTIONS π
The following command-line options are recognized by ocamlrun(1).
-bβ When your program aborts because an uncaught exception happened, this prints a detailed "back trace" of the execution, showing where the exception was raised and which function calls were outstanding at that point. It only prints if the bytecode executable contains debugging information, i.e. it was compiled and linked with the-goption toocamlc(1)set. This option is equivalent to setting thebflag in theOCAMLRUNPARAMenvironment variable (see below).-I dirβ Search the directory dir for dynamically-loaded libraries, in addition to the standard search path.-m fileβ Print the magic number of the bytecode executable file and exit.-Mβ Print the magic number expected for bytecode executables by this version of the runtime and exit.-pβ Print the names of the primitives known to this version ofocamlrun(1)and exit.-tβ Increment the trace level for the debug runtime (ignored by the standard runtime).-vβ Direct the memory manager to print verbose messages on standard error. This is equivalent to settingv=63in theOCAMLRUNPARAMenvironment variable (see below).-versionβ Print version string and exit.-vnumβ Print short version number and exit.
π¦ ENVIRONMENT VARIABLES π¦
The following environment variables are also consulted:
CAML_LD_LIBRARY_PATHβ Additional directories to search for dynamically-loaded libraries.OCAMLLIBβ The directory containing the OCaml standard library. (IfOCAMLLIBis not set,CAMLLIBwill be used instead.) Used to locate theld.confconfiguration file for dynamic loading. If not set, default to the library directory specified when compiling OCaml.OCAMLRUNPARAMβ Set the runtime system options and garbage collection parameters. (IfOCAMLRUNPARAMis not set,CAMLRUNPARAMwill 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 by0x), and an optional multiplier. If the letter is followed by anything else, the corresponding option is set to1. Unknown letters are ignored. The options are documented below; the optionsl,m,M,n,o,s,vcorrespond to the fields of the control record documented in The OCaml user's manual, chapter "Standard Library", section "Gc".bβ Trigger the printing of a stack backtrace when an uncaught exception aborts the program. This option takes no argument.c(cleanup_on_exit) β Shut the runtime down gracefully on exit. The option also enables pooling (as incaml_startup_pooled). This mode can be used to detect leaks with a third-party memory debugger.d(max_domains) β Maximum number of domains that can be active concurrently. Defaults to128on 64-bit platforms and16on 32-bit platforms.e(runtime_events_log_wsize) β Size of the per-domain runtime events ring buffers in log powers of two words. Defaults to16, giving64kword or512kbbuffers on 64-bit systems.l(stack_limit) β The limit (in words) of the stack size.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 withcaml_alloc_custom_mem(e.g. bigarrays). Default:100.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 withcaml_alloc_custom_mem(e.g. bigarrays). Default:44.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 againstcustom_minor_ratioand the rest is directly counted againstcustom_major_ratio. Note: this only applies to values allocated withcaml_alloc_custom_mem(e.g. bigarrays). Default:8192bytes.o(space_overhead) β The main major GC speed setting.pβ Turn on debugging support forocamlyacc-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.Rβ Turn on randomization of all hash tables by default (see theHashtblmodule of the standard library). This option takes no argument.s(minor_heap_size) β The size of the minor heap (in words).tβ Set the trace level for the debug runtime (ignored by the standard runtime).v(verbose) β What GC messages to print to stderr. This is a sum of values selected from the following: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 asGc.print_stat.0x800β GC debugging messages.0x1000β Address space reservation changes.
V(verify_heap) β Runs an integrity check on the heap just after the completion of a major GC cycle.Wβ Print runtime warnings to stderr (such as Channel opened on file dies without being closed, unflushed data, etc.)
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. Slay. β¨
CAMLRUNPARAMβ IfOCAMLRUNPARAMis not found in the environment, thenCAMLRUNPARAMwill be used instead. IfCAMLRUNPARAMis also not found, then the default values will be used.PATHβ List of directories searched to find the bytecode executable file.
π SEE ALSO π
ocamlc(1).- The OCaml user's manual, chapter "Runtime system".
Source/version/date sign-off: this is OCAMLRUN(1) from the General Commands Manual. The original footer didn't print a date, so no fake date here, bestie. π
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- nixpkgs unstable: ocaml 5.5.1
- nixpkgs unstable: ocaml-solo5 1.3.5
- Copyright 1996 Institut National de Recherche en Informatique et
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms