Skip to content

Commit 30958ea

Browse files
committed
fix(ocr): invoke cleanup during OCR reinitialization to prevent memory leaks
1 parent 9a1d0fd commit 30958ea

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/one_dragon/base/operation/one_dragon_context.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,11 @@ def init_ocr(self) -> None:
484484
初始化OCR
485485
:return:
486486
"""
487+
# 清理旧实例资源
488+
if hasattr(self, 'ocr') and self.ocr is not None:
489+
if hasattr(self.ocr, 'cleanup'):
490+
self.ocr.cleanup()
491+
487492
self.ocr = OnnxOcrMatcher(
488493
OnnxOcrParam(
489494
ocr_model_name=self.model_config.ocr,

0 commit comments

Comments
 (0)