Skip to content

Commit 82b3f99

Browse files
committed
Fix memory leak in TempAllocator::free()
1 parent 63022e1 commit 82b3f99

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

python/jittor/src/mem/allocator/temp_allocator.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ void TempAllocator::free(void* mem_ptr, size_t size, const size_t& allocation) {
8181
auto it = cached_blocks.lower_bound(get_key(block));
8282
if (it == cached_blocks.begin()) {
8383
can_add = false;
84+
underlying->free((void*)block->memory_ptr, block->size, 0);
85+
unused_memory -= block->size;
86+
block_ids.push_back(block->id);
87+
delete block;
8488
} else {
8589
--it;
8690
TempCachingBlock* block = it->second;

0 commit comments

Comments
 (0)