Skip to content

Commit

Permalink
Merge pull request #509 from uyzhang/master
Browse files Browse the repository at this point in the history
Fix memory leak in TempAllocator::free()
  • Loading branch information
MenghaoGuo authored Apr 25, 2024
2 parents 63022e1 + 82b3f99 commit 80004c2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/jittor/src/mem/allocator/temp_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ void TempAllocator::free(void* mem_ptr, size_t size, const size_t& allocation) {
auto it = cached_blocks.lower_bound(get_key(block));
if (it == cached_blocks.begin()) {
can_add = false;
underlying->free((void*)block->memory_ptr, block->size, 0);
unused_memory -= block->size;
block_ids.push_back(block->id);
delete block;
} else {
--it;
TempCachingBlock* block = it->second;
Expand Down

0 comments on commit 80004c2

Please sign in to comment.