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

@@ -150,6 +150,18 @@ public:
private:
TRTEngineCache() = default;
~TRTEngineCache() {
if (g_processExiting().load(std::memory_order_relaxed)) {
// ExitProcess path: CUDA context is dead. Leak ICudaEngine and
// IRuntime shared_ptrs so their destructors don't call into a
// destroyed CUDA driver. The OS reclaims everything at exit.
for (auto& [_, entry] : m_cache) {
auto* le = new std::shared_ptr<nvinfer1::ICudaEngine>(std::move(entry.engine));
auto* lr = new std::shared_ptr<nvinfer1::IRuntime>(std::move(entry.runtime));
(void)le; (void)lr; // intentional leak
}
}
}
TRTEngineCache(const TRTEngineCache&) = delete;
TRTEngineCache& operator=(const TRTEngineCache&) = delete;