Skip to content

Commit 80004c2

Browse files
authored
Merge pull request #509 from uyzhang/master
Fix memory leak in TempAllocator::free()
2 parents 63022e1 + 82b3f99 commit 80004c2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

+4
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)