A service needs a way to limit one worker’s memory without stopping every other worker. Hew 0.10 makes an actor’s memory budget follow the values it owns. Native stack exhaustion also enters the failure and supervision path, so a supervisor can restart a child after it runs out of stack.
Give an actor a memory budget
The max_heap annotation limits the managed values an actor keeps, including its state, collections and message payloads:
#[max_heap(4096)]
actor Batch {
var lines: Vec<string> = Vec.new();
receive fn add(line: string) -> i64 {
lines.push(line);
lines.len()
}
}
fn main() {
let batch = spawn Batch;
println(batch.add("first").expect("batch is available"));
println(batch.add("second").expect("batch is available"));
}Running this program prints 1 and 2. The strings and the vector’s backing storage count towards the actor’s 4,096-byte budget. If later growth exceeds that budget, the actor fails with HeapExceeded and follows its supervision policy. Copies that share immutable backing are charged once to each actor keeping that backing alive.
The budget covers language-managed payload storage. Allocator bookkeeping, stack memory and operating-system resources need their own limits. If an application needs a hard limit on total process memory, use a process or component boundary as well.
Recover a worker after stack exhaustion
A supervised native child that exhausts its stack can now fail with StackOverflow and restart. Cleanup has a reserved part of the stack so the failure path can release owned values. A child without supervision still terminates with a diagnostic.
Supervised children restart immediately unless a backoff is declared. A child’s own backoff: clause can override its supervisor’s delay, and restart.immediate() disables that delay for the child. Memory budgets and stack limits remain separate choices.
Long method, field and index chains also compile without adding one recursive compiler frame for every link. This applies to native compilation and the browser compiler. Excessively nested prefix expressions receive a nesting diagnostic.
Keep a native authoring session open
The Linux x86_64 SDK includes experimental persistent native authoring through hew tool live. Declarations and bindings persist between submissions, initializers run once, and :clear completes cleanup. The live tools guide covers setup, typed services and replacement. Other platform archives keep the ordinary compiler tools.
For a small command-line filter, hew eval --lines compiles one body and runs it for each input line:
printf 'first\n\nlast\n' | hew eval --lines 'if line != "" { println(line); }'The output is first followed by last. The body receives an immutable line: string and uses ordinary Hew control flow and cleanup.
Upgrade
Install the matching compiler, runtime and headers, then rebuild native modules and bindings:
curl -fsSL https://hew.sh/install | bash -s -- --version 0.10.0Hew 0.10 continues edition 2026. The release notes cover codec corrections, persistent service grants across connection replacement and the remaining runtime changes. First-class failure traces and the expanded debugging API are planned for 0.11.