#!/usr/bin/env bash # Wrapper so run-canary-native.sh runs xenia under heaptrack (host-malloc leak # profiler). Usage: # sudo apt install heaptrack # one-time # CANARY_BIN="$PWD/tools/heaptrack-wrap.sh" tools/run-canary-native.sh # Then: boot -> into a menu/READY ROOM (or a short mission) so RSS climbs a few # hundred MB, then QUIT xenia normally (window close / menu quit) so heaptrack # flushes its dump. Output: /tmp/xenia-heaptrack.*.zst (or .gz). Tell Claude and # it will run heaptrack_print/analyze to name the leaking call stacks. set -u HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" WORKSPACE="$(cd "$HERE/../.." && pwd)" REAL_BIN="${CANARY_REAL_BIN:-$WORKSPACE/xenia-canary-native/build/bin/Linux/Release/xenia_canary}" exec heaptrack -o /tmp/xenia-heaptrack "$REAL_BIN" "$@"