Skip to content

Commit a3c2fae

Browse files
authored
Fix ONNX Runtime Op memory leak (#2406)
1 parent 6fdf459 commit a3c2fae

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

csrc/mmdeploy/backend_ops/onnxruntime/modulated_deform_conv/modulated_deform_conv.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ void MMCVModulatedDeformConvKernel::Compute(OrtKernelContext *context) {
190190
group, deformable_group, channels, num_output, kernel_height,
191191
kernel_width, stride_height, stride_width, padding_height,
192192
padding_width, dilation_height, dilation_width, columns, out_ptr);
193+
194+
allocator_.Free(columns);
193195
}
194196
REGISTER_ONNXRUNTIME_OPS(mmdeploy, MMCVModulatedDeformConvOp);
195197
REGISTER_ONNXRUNTIME_OPS(mmcv, MMCVModulatedDeformConvOp);

csrc/mmdeploy/backend_ops/onnxruntime/nms_rotated/nms_rotated.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ void NMSRotatedKernel::Compute(OrtKernelContext* context) {
358358
int64_t* res_data = ort_.GetTensorMutableData<int64_t>(res);
359359

360360
memcpy(res_data, res_order.data(), sizeof(int64_t) * res_order.size());
361+
362+
allocator_.Free(tmp_boxes);
363+
allocator_.Free(sc);
364+
allocator_.Free(select);
361365
}
362366

363367
REGISTER_ONNXRUNTIME_OPS(mmdeploy, NMSRotatedOp);

0 commit comments

Comments
 (0)