Skip to content

Commit 4a2b33b

Browse files
committed
Explicitly delete unused result to avoid memory leak
1 parent ae54ee9 commit 4a2b33b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tfjs-backend-wasm/src/kernels/NonMaxSuppressionV3.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ function kernelFunc(args: {
6464
const resOffset =
6565
wasmFunc(boxesId, scoresId, maxOutputSize, iouThreshold, scoreThreshold);
6666

67-
const {pSelectedIndices, selectedSize} =
67+
const {pSelectedIndices, selectedSize, pSelectedScores} =
6868
parseResultStruct(backend, resOffset);
6969

70+
// Since we are not using scores for V3, we have to delete it from the heap.
71+
backend.wasm._free(pSelectedScores);
72+
7073
const selectedIndicesTensor =
7174
backend.makeOutput([selectedSize], 'int32', pSelectedIndices);
7275

0 commit comments

Comments
 (0)