Merge pull request #509 from uyzhang/master

Fix memory leak in TempAllocator::free()
This commit is contained in:
MenghaoGuo 2024-04-25 21:53:02 +08:00 committed by GitHub
commit 80004c2928
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 0 deletions

View File

@ -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;