Prevent OOM

This commit is contained in:
2026-06-18 05:55:31 +10:00
parent ebba70b9d9
commit b3436a61ee
44 changed files with 1797 additions and 66 deletions
@@ -2,6 +2,7 @@
#include "ANSGpuFrameRegistry.h"
#include "ANSEngineCommon.h"
#include "ANSLicense.h" // ANS_DBG macro
#include "GpuMemoryGuard.h"
#include <opencv2/cudaimgproc.hpp>
#include <opencv2/cudawarping.hpp>
#include <opencv2/core/cuda_stream_accessor.hpp>
@@ -168,6 +169,12 @@ namespace ANSCENTER {
}
++m_cudaFailStreak;
// (3) If this failure is a GPU OOM, open the process-wide circuit
// breaker so every engine (FR/OD/OCR/LPR) backs off via UnderPressure()
// before the streak reaches CUDA_FAIL_LIMIT and the context is lost.
if (GpuMemoryGuard::IsOom(err) || GpuMemoryGuard::IsOom(pending)) {
GpuMemoryGuard::NoteOom();
}
if (m_cudaFailStreak >= CUDA_FAIL_LIMIT && !m_cudaContextDead) {
m_cudaContextDead = true;
logger.LogFatal(std::string(tag) + "::NV12Helper",