Skip to content

Commit 0910e0a

Browse files
ezyangsoumith
authored andcommitted
Fix memory leak in coalesce. (pytorch#1460)
Fixes pytorch#1449. For future reference, we should have a doc explaining our ref-counting conventions; it looks like this bug slipped by because we assumed that newTensor was taking ownership of the pointers it was passed in. Signed-off-by: Edward Z. Yang <ezyang@fb.com>
1 parent 9309429 commit 0910e0a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

torch/lib/THCS/generic/THCSTensor.cu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ THCSTensor *THCSTensor_(newCoalesce)(THCState *state, THCSTensor *self) {
164164

165165
THCIndexTensor_(free)(state, indices);
166166
THCTensor_(free)(state, values);
167+
THCIndexTensor_(free)(state, newIndices);
168+
THCTensor_(free)(state, newValues);
167169

168170
dst->coalesced = 1;
169171
THCudaCheck(cudaGetLastError());

0 commit comments

Comments
 (0)