Fix ANSOCR TensorRT Release

This commit is contained in:
2026-03-30 09:24:04 +11:00
parent b735931c55
commit 01eabf76bd
5 changed files with 57 additions and 3 deletions

View File

@@ -323,7 +323,19 @@ private:
// unreliable. Don't destroy Engine objects (their destructors
// call cudaFree, thread::join, etc. which deadlock or crash).
// The OS reclaims all memory, VRAM, and handles at process exit.
//
// Intentionally leak Engine shared_ptrs: after the explicit dtor
// body returns, the compiler still runs implicit member dtors for
// m_pools. That would destroy shared_ptr<Engine<T>>, triggering
// TRT/CUDA cleanup on a dead context. Detach the shared_ptrs
// first so the map destructor only frees empty entries.
m_sweeperRunning.store(false);
// Leak Engine objects: bump refcount so shared_ptr dtor won't
// actually delete them when m_pools is implicitly destroyed.
for (auto& [_, entry] : m_pools) {
auto* leaked = new std::shared_ptr<Engine<T>>(std::move(entry.engine));
(void)leaked; // intentional leak — OS reclaims at exit
}
return;
}
// Normal FreeLibrary path: threads are alive, safe to clean up.