feat(ludic.physics): Jolt's heap counted in the shim (plan 25) - jph_heap_bytes/peak/allocs, phys_heap_bytes/peak/allocs

Jolt's Allocate/Reallocate/Free/AlignedAllocate/AlignedFree go to libc's malloc with the size in a
16-byte header, and atomic counters keep live bytes, the peak and the blocks asked for (its job
threads allocate too). The fence reads the three exports extern_weak to judge Jolt by its plateau.
jolt_heap_test: a ground in and out 1100 times holds 46,482,514 bytes after the first 100 and after
all of them, the peak does not move, and a closed world gives back every byte it took. The macOS
library is rebuilt; the Windows DLL still has to be rebuilt on the PC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 15:49:38 +03:00
parent 7fdd6582be
commit e9de2b6f27
5 changed files with 115 additions and 4 deletions

View file

@ -120,10 +120,12 @@ void *keep(const ShapeSettings::ShapeResult &r) {
}
} // namespace
// Jolt's allocator, factory and types, once per process; 0 when ready
#include "jph_alloc.inl"
// Jolt's allocator (counted, jph_alloc.inl), factory and types, once per process; 0 when ready
JPH_SHIM int jph_init(void) {
if (g_ready) return 0;
RegisterDefaultAllocator();
heap_register();
Factory::sInstance = new Factory();
RegisterTypes();
g_ready = true;