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 | 28 | |
29 | 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 | 37 | ret = aclrtDestroyContext(context_); |
40 | 38 | if (ret != ACL_SUCCESS) { |
41 | 39 | LOG_ERROR("destroy context failed"); |
42 | 40 | } |
43 | 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 | 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 | 101 | } |
109 | 102 | |
110 | 103 | aclError ret; |
111 | - aclrtSetDevice(deviceId_); | |
112 | 104 | ret = aclrtSetCurrentContext(context_); |
113 | 105 | if (ret != ACL_SUCCESS) { |
114 | 106 | LOG_ERROR("aclrtSetCurrentContext failed"); |
... | ... | @@ -194,7 +186,6 @@ int VPCUtil::init(int32_t devId){ |
194 | 186 | deviceId_ = devId; |
195 | 187 | |
196 | 188 | aclError ret; |
197 | - aclrtSetDevice(deviceId_); | |
198 | 189 | aclrtCreateContext(&context_, deviceId_); |
199 | 190 | |
200 | 191 | // channel 准备 |
... | ... | @@ -212,7 +203,6 @@ vector<vpc_img_info> VPCUtil::crop_batch(DeviceMemory *devMem, vector<video_obje |
212 | 203 | } |
213 | 204 | |
214 | 205 | aclError ret; |
215 | - aclrtSetDevice(deviceId_); | |
216 | 206 | ret = aclrtSetCurrentContext(context_); |
217 | 207 | |
218 | 208 | // 输入 | ... | ... |