From 45e07c6d10a8c20a257ef20fa72f470ec6127308 Mon Sep 17 00:00:00 2001 From: cmhu <2657262686@qq.com> Date: Fri, 23 Aug 2024 16:39:13 +0800 Subject: [PATCH] 优化dvppChannelDesc_释放,避免泄露 --- src/util/vpc_util.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/util/vpc_util.cpp b/src/util/vpc_util.cpp index 91b9c81..4423132 100755 --- a/src/util/vpc_util.cpp +++ b/src/util/vpc_util.cpp @@ -28,26 +28,19 @@ static uint32_t AlignSize(uint32_t origSize, uint32_t alignment){ void VPCUtil::release() { - aclError ret; - // ret = aclrtSetDevice(deviceId_); - // aclrtSetCurrentContext(context_); + if (context_ != nullptr) { + aclrtSetCurrentContext(context_); - ret = acldvppDestroyChannel(dvppChannelDesc_); - ret = acldvppDestroyChannelDesc(dvppChannelDesc_); + aclError ret = acldvppDestroyChannel(dvppChannelDesc_); + ret = acldvppDestroyChannelDesc(dvppChannelDesc_); - if (context_ != nullptr) { ret = aclrtDestroyContext(context_); if (ret != ACL_SUCCESS) { LOG_ERROR("destroy context failed"); } context_ = nullptr; } - LOG_INFO("end to destroy context"); - ret = aclrtResetDevice(deviceId_); - if (ret != ACL_SUCCESS) { - LOG_ERROR("reset device failed"); - } LOG_INFO("end to reset device is %d", deviceId_); } @@ -108,7 +101,6 @@ vpc_img_info VPCUtil::crop(DeviceMemory *devMem, video_object_info obj) { } aclError ret; - aclrtSetDevice(deviceId_); ret = aclrtSetCurrentContext(context_); if (ret != ACL_SUCCESS) { LOG_ERROR("aclrtSetCurrentContext failed"); @@ -194,7 +186,6 @@ int VPCUtil::init(int32_t devId){ deviceId_ = devId; aclError ret; - aclrtSetDevice(deviceId_); aclrtCreateContext(&context_, deviceId_); // channel 准备 @@ -212,7 +203,6 @@ vector VPCUtil::crop_batch(DeviceMemory *devMem, vector