Fix tenant_mutil_allcator memory leak issue.

This commit is contained in:
jiadebinmary@gmail.com 2023-09-15 05:10:06 +00:00 committed by ob-robot
parent c4a72202a9
commit fd3d7d13a3
3 changed files with 27 additions and 2 deletions

View File

@ -61,6 +61,26 @@ ObTenantMutilAllocator::ObTenantMutilAllocator(uint64_t tenant_id)
}
}
ObTenantMutilAllocator::~ObTenantMutilAllocator()
{
OB_LOG(INFO, "~ObTenantMutilAllocator", K(tenant_id_));
destroy();
}
void ObTenantMutilAllocator::destroy()
{
OB_LOG(INFO, "ObTenantMutilAllocator destroy", K(tenant_id_));
clog_ge_alloc_.destroy();
log_io_flush_log_task_alloc_.destroy();
log_io_truncate_log_task_alloc_.destroy();
log_io_flush_meta_task_alloc_.destroy();
log_io_truncate_prefix_blocks_task_alloc_.destroy();
log_io_flashback_task_alloc_.destroy();
log_io_purge_throttling_task_alloc_.destroy();
palf_fetch_log_task_alloc_.destroy();
replay_log_task_alloc_.destroy();
}
int ObTenantMutilAllocator::choose_blk_size(int obj_size)
{
static const int MIN_SLICE_CNT = 64;

View File

@ -95,8 +95,8 @@ public:
public:
explicit ObTenantMutilAllocator(uint64_t tenant_id);
~ObTenantMutilAllocator()
{}
~ObTenantMutilAllocator();
void destroy();
// update nway when tenant's max_cpu changed
void set_nway(const int32_t nway);
// update limit when tenant's memory_limit changed

View File

@ -252,8 +252,11 @@ int ObTenantMutilAllocatorMgr::delete_tenant_mutil_allocator_(const uint64_t ten
if (NULL != (tma_allocator = ATOMIC_LOAD(&tma_array_[tenant_id]))) {
if (NULL != tma_allocator->get_next()) {
OB_LOG(INFO, "next_ ptr is not NULL, skip deleting this allocator", K(ret), K(tenant_id));
// Purge cached blocks of this allocator.
tma_allocator->try_purge();
} else {
tma_array_[tenant_id] = NULL;
// destroy tma object
tma_allocator->~TMA();
ob_free(tma_allocator);
tma_allocator = NULL;
@ -276,6 +279,8 @@ int ObTenantMutilAllocatorMgr::delete_tenant_mutil_allocator_(const uint64_t ten
OB_ASSERT(prev != cur);
prev->get_next() = cur->get_next();
cur->get_next() = NULL;
// destroy tma object
cur->~TMA();
ob_free(cur);
cur = NULL;
}