ludic/docs/language/os/os-heap_bytes.md
Orkuncakilkaya 22d1e2d66a Os.heap_bytes: the heap without the renderer; string_temps reads it
Vk.heap_bytes pulled the Vk module - and on lang/uifree the GL window path - into a plain program,
which then failed to link (_cgl_offscreen, lgl_GetError). Os.heap_bytes is malloc_zone_statistics
through a weak reference (0 where there is none, and on Windows). Reseeded. Docs for it and for
Json.free / Json.free_all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 12:31:42 +03:00

718 B

id name category kind tokens sig tip order ns member
os-heap_bytes Os.heap_bytes os namespace-method Os.heap_bytes Os.heap_bytes() -> long malloc's live bytes (macOS; 0 elsewhere). 19 Os heap_bytes

The bytes malloc holds live across every zone of the process, on macOS; 0 on other platforms. Ludic has no garbage collector, so a path that runs every frame must give back all it takes: read this before and after many rounds of it, and the difference is what it keeps. A test built on it should allow for 0 elsewhere.

program Heap {
  entry {
    let before = Os.heap_bytes()
    var n = 0
    for i in 0 .. 1000 { if `{i}` == "7" { n += 1 } }
    print(Os.heap_bytes() - before)
  }
}