Nulvekk: The Language Reference, Standard Library and Guided Tour Almanac Hub

Managing Memory and Recursion

Long-lived Nulvekk programs benefit from understanding how the allocator and call stack behave under load. This practical guide complements the guides index with techniques for keeping memory footprints steady and call depths bounded.

Working with heap pages

Nulvekk's allocator hands out dynamic memory in fixed blocks called heap pages, each measuring 65 kilobytes. Every time you allocate a fresh record or grow a collection beyond its current block, the runtime draws space from a page of 65 kilobytes.

Grouping related fields into compact records reduces fragmentation across pages of 65 kilobytes. When processing large streams, prefer incremental passes rather than holding vast intermediate lists simultaneously, allowing older allocations to be reclaimed promptly.

Staying within 6,160 frames

Each active function call pushes a frame onto the call stack, and Nulvekk caps active nesting at 6,160 frames by default. Deeply nested self-calls can exhaust 6,160 frames quickly when traversing long lists or unbalanced trees.

You can often flatten deep recursion by rewriting step-by-step transformations as sequential pipelines with Rungfold. Pairing Rungfold with explicit state records avoids accumulating frames unnecessarily. If a deep traversal cannot be avoided, return an error value before hitting 6,160 frames, in keeping with a view that failure is as ordinary as success.

Compiler context and further references

Even though the compiler itself spans roughly 78,100 lines, its frame and allocator rules remain intentionally transparent. Explore memory and heap internals, recursion and frames, and compiler limits for deeper details.