# Self-host leak budget.
#
# One line per canonical compiler invocation:
#
#   <case> <max_leaked_allocations>
#
# Enforced by compiler/tools/bash/leakcheck-selfhost.sh, which builds the
# self-hosted compiler with `--asan` and reads LeakSanitizer's own count of
# blocks still unreachable at exit. `<case>` names a fixed command in that
# script, not a test file, so the numbers are comparable run to run.
#
# Why a budget and not zero, when the C compiler is held to zero: the C
# compiler allocates from an arena it frees on the way out, so LSan sees
# nothing. Salam is manually memory-managed and has no arena behind its
# string temporaries, so every discarded `a + b` in compiler/*.salam is a
# live block until the process exits. Getting to zero means changing how the
# self-hosted compiler allocates, not adding a handful of frees - and until
# then a ratchet is what keeps the number from silently growing.
#
# This is a ratchet: the script FAILS when a case leaks more than its number
# and WARNS ("under budget - lower it") when it leaks less. Lower the number
# in the same change that improved it. The goal is every line at 0.
#
# Each number is the observed count plus ~2% headroom, and the script's
# "lower it" nag has a 5% deadband. Repeated runs of one binary on one machine
# are identical to the allocation, but the count drifts by a few dozen BETWEEN
# machines: the compiler allocates while walking absolute paths, and
# /home/runner/work/Salam/Salam is not the length of anyone's local checkout.
# An exact ratchet would have failed CI on a 28-allocation difference that
# said nothing about the compiler.
#
# Measured 2026-08-08 on Linux/x86-64, gcc 13, on both a local checkout and a
# GitHub ubuntu-latest runner (observed: version 6269, help 6257, format 6477,
# inspect 126078-126100, exec 130515-130528, build 230706-230734). The
# starting point was roughly twice these figures before three fixes landed
# together with this file:
#   - logger.New no longer reserves 512 diag-source slots (12 KB) for every
#     Logger ever default-constructed - one per Lx/Ps/Sema/Codegen
#   - langpack has_join_char stopped allocating a per-character Vector<str>
#     for every identifier the lexer scans
#   - io.ReadAll releases each 4 KB read buffer instead of dropping it, and
#     source.Free lets the schema/std-index scans release file text they are
#     done with
# `salam version` went from 4,349,628 bytes leaked to 148,810.

version 6400
help 6400
format 6620
inspect 128700
exec 133200
build 235400
