ggml_metal_rsets_free() did GGML_ASSERT([rsets->data count] == 0) and so called abort() when the Metal device is torn down (a C++ static destructor at process exit) while residency sets are still registered. On macOS 15+ this crashes the app on every quit: a residency set is removed from the collection only by ggml_metal_buffer_free(), so an app that exits without freeing every buffer (letting the OS reclaim the model on quit) leaves sets registered. The device does not own the buffers and cannot free them from its destructor, so make teardown defensive instead: stop the keep-alive heartbeat, then wind down residency on any leftover sets (endResidency + removeAllAllocations, mirroring ggml_metal_buffer_rset_free but without -release, since each set is still owned by its not-yet-freed buffer) before releasing the collection. The backing buffers are reclaimed by the OS as the process exits. No behavior change when all buffers were freed (the array is empty). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| cmake | ||
| include | ||
| src | ||
| .gitignore | ||
| CMakeLists.txt | ||