Commit 45e07c6d10a8c20a257ef20fa72f470ec6127308
1 parent
a9e0f30b
优化dvppChannelDesc_释放,避免泄露
Showing
1 changed file
with
4 additions
and
14 deletions
src/util/vpc_util.cpp
@@ -28,26 +28,19 @@ static uint32_t AlignSize(uint32_t origSize, uint32_t alignment){ | @@ -28,26 +28,19 @@ static uint32_t AlignSize(uint32_t origSize, uint32_t alignment){ | ||
28 | 28 | ||
29 | void VPCUtil::release() | 29 | void VPCUtil::release() |
30 | { | 30 | { |
31 | - aclError ret; | ||
32 | - // ret = aclrtSetDevice(deviceId_); | ||
33 | - // aclrtSetCurrentContext(context_); | 31 | + if (context_ != nullptr) { |
32 | + aclrtSetCurrentContext(context_); | ||
34 | 33 | ||
35 | - ret = acldvppDestroyChannel(dvppChannelDesc_); | ||
36 | - ret = acldvppDestroyChannelDesc(dvppChannelDesc_); | 34 | + aclError ret = acldvppDestroyChannel(dvppChannelDesc_); |
35 | + ret = acldvppDestroyChannelDesc(dvppChannelDesc_); | ||
37 | 36 | ||
38 | - if (context_ != nullptr) { | ||
39 | ret = aclrtDestroyContext(context_); | 37 | ret = aclrtDestroyContext(context_); |
40 | if (ret != ACL_SUCCESS) { | 38 | if (ret != ACL_SUCCESS) { |
41 | LOG_ERROR("destroy context failed"); | 39 | LOG_ERROR("destroy context failed"); |
42 | } | 40 | } |
43 | context_ = nullptr; | 41 | context_ = nullptr; |
44 | } | 42 | } |
45 | - LOG_INFO("end to destroy context"); | ||
46 | 43 | ||
47 | - ret = aclrtResetDevice(deviceId_); | ||
48 | - if (ret != ACL_SUCCESS) { | ||
49 | - LOG_ERROR("reset device failed"); | ||
50 | - } | ||
51 | LOG_INFO("end to reset device is %d", deviceId_); | 44 | LOG_INFO("end to reset device is %d", deviceId_); |
52 | } | 45 | } |
53 | 46 | ||
@@ -108,7 +101,6 @@ vpc_img_info VPCUtil::crop(DeviceMemory *devMem, video_object_info obj) { | @@ -108,7 +101,6 @@ vpc_img_info VPCUtil::crop(DeviceMemory *devMem, video_object_info obj) { | ||
108 | } | 101 | } |
109 | 102 | ||
110 | aclError ret; | 103 | aclError ret; |
111 | - aclrtSetDevice(deviceId_); | ||
112 | ret = aclrtSetCurrentContext(context_); | 104 | ret = aclrtSetCurrentContext(context_); |
113 | if (ret != ACL_SUCCESS) { | 105 | if (ret != ACL_SUCCESS) { |
114 | LOG_ERROR("aclrtSetCurrentContext failed"); | 106 | LOG_ERROR("aclrtSetCurrentContext failed"); |
@@ -194,7 +186,6 @@ int VPCUtil::init(int32_t devId){ | @@ -194,7 +186,6 @@ int VPCUtil::init(int32_t devId){ | ||
194 | deviceId_ = devId; | 186 | deviceId_ = devId; |
195 | 187 | ||
196 | aclError ret; | 188 | aclError ret; |
197 | - aclrtSetDevice(deviceId_); | ||
198 | aclrtCreateContext(&context_, deviceId_); | 189 | aclrtCreateContext(&context_, deviceId_); |
199 | 190 | ||
200 | // channel 准备 | 191 | // channel 准备 |
@@ -212,7 +203,6 @@ vector<vpc_img_info> VPCUtil::crop_batch(DeviceMemory *devMem, vector<video_obje | @@ -212,7 +203,6 @@ vector<vpc_img_info> VPCUtil::crop_batch(DeviceMemory *devMem, vector<video_obje | ||
212 | } | 203 | } |
213 | 204 | ||
214 | aclError ret; | 205 | aclError ret; |
215 | - aclrtSetDevice(deviceId_); | ||
216 | ret = aclrtSetCurrentContext(context_); | 206 | ret = aclrtSetCurrentContext(context_); |
217 | 207 | ||
218 | // 输入 | 208 | // 输入 |