Home / Docs / Configure a package
[run] max_memory
What it does
A running program holds memory for its values: lists, maps, text. una run stops a run that holds more than its memory budget, 4096 MiB unless told otherwise, and reports where. max_memory declares the package's own budget, in MiB, so every run of it has the same limit: una run, una test and the executable una build makes.
In edition 0.3 it is a key of [run] in una.toml:
[package]
name = "meter"
version = "0.1.0"
edition = "0.3"
[run]
entry = "meter"
grants = ["console"]
max_memory = 64module meter
pub main() -> Unit
uses @console: Console[print]
=
@console.print("ready")From edition 0.4 it is a line of run in ita.una, after entry:
ita meter
version 0.1.0
edition 0.4
run
entry meter
max_memory 64
grants
consolemodule meter
pub main() -> Unit
uses @console: Console[print]
=
@console.print("ready")Forms
[run]
max_memory = <MiB> -- una.toml, edition 0.3
run
max_memory <MiB> -- ita.una, edition 0.4An integer from 1 to 4096.
Examples
A budget outside that range is rejected:
[package]
name = "meter"
version = "0.1.0"
edition = "0.3"
[run]
entry = "meter"
grants = ["console"]
max_memory = 0-- fails with U7002
module meter
pub main() -> Unit
uses @console: Console[print]
=
@console.print("ready")The same in ita.una is U7008 at the value:
-- fails with U7008
ita meter
version 0.1.0
edition 0.4
run
entry meter
max_memory 8192
grants
consolemodule meter
pub main() -> Unit
uses @console: Console[print]
=
@console.print("ready")Edge cases
The flag may lower the budget, never raise it. With max_memory = 64, --max-memory 32 runs with 32 MiB, and --max-memory 128 stops with a usage error, exit code 2, before the program starts: --max-memory 128 is above the package's declared max_memory of 64 MiB; it may lower the budget, never raise it. The same holds for una test and for the built executable, which carries the budget in its embedded description.
Further rules:
- Without a declaration, the budget is 4096 MiB, and
--max-memorysets it, to any value of at least 1. - A
systemspackage that runs must declare it. See[package] profile. - Why 4096. While editions
0.3and0.4are previews, a declared budget never exceeds the default, so declaring one never lets a program run further than it would without it. - The report prints
max memory: 64 MiBunder the package's name when the budget is declared.
Diagnostics
- U7002: in
una.toml, amax_memorythat is not an integer from 1 to 4096, or amax_memorykey before edition0.3. - U7008: in
ita.una, amax_memoryoutside 1 to 4096, at its value.
Edition
max_memory exists from edition 0.3, which is a preview, as a key of una.toml, and in edition 0.4, also a preview, as a line of ita.una. In editions 0.1 and 0.2 it is an unknown key.
Normative source
- spec/13 §7: project files; spec/13 §5:
una runand its flags; spec/30 §2:ita.una. - spec/11 §7: the memory budget of a run.
- Decision record: ADR 0109.