fix mem leak

This commit is contained in:
yihaoDeng 2023-10-20 20:49:01 +08:00
parent 3c719da5b5
commit e95735eea4
1 changed files with 22 additions and 8 deletions

View File

@ -1467,16 +1467,24 @@ rocksdb_compactionfilter_t* compactFilteFactoryCreateFilter(void* arg, rocksdb_c
void destroyRocksdbCfInst(RocksdbCfInst* inst) { void destroyRocksdbCfInst(RocksdbCfInst* inst) {
int cfLen = sizeof(ginitDict) / sizeof(ginitDict[0]); int cfLen = sizeof(ginitDict) / sizeof(ginitDict[0]);
if (inst->pHandle) {
for (int i = 0; i < cfLen; i++) { for (int i = 0; i < cfLen; i++) {
if (inst->pHandle[i]) rocksdb_column_family_handle_destroy((inst->pHandle)[i]); if (inst->pHandle[i]) rocksdb_column_family_handle_destroy((inst->pHandle)[i]);
} }
taosMemoryFree(inst->pHandle);
}
rocksdb_writeoptions_destroy(inst->wOpt); if (inst->cfOpt) {
inst->wOpt = NULL; for (int i = 0; i < cfLen; i++) {
rocksdb_options_destroy(inst->cfOpt[i]);
rocksdb_readoptions_destroy(inst->rOpt); rocksdb_block_based_options_destroy(((RocksdbCfParam*)inst->param)[i].tableOpt);
taosMemoryFree(inst->cfOpt); }
taosMemoryFreeClear(inst->cfOpt);
taosMemoryFreeClear(inst->param); taosMemoryFreeClear(inst->param);
}
if (inst->wOpt) rocksdb_writeoptions_destroy(inst->wOpt);
if (inst->rOpt) rocksdb_readoptions_destroy(inst->rOpt);
taosMemoryFree(inst); taosMemoryFree(inst);
} }
@ -1645,6 +1653,12 @@ int streamStateOpenBackend(void* backend, SStreamState* pState) {
pState->pTdbState->backendCfWrapperId = id; pState->pTdbState->backendCfWrapperId = id;
pState->pTdbState->pBackendCfWrapper = pBackendCfWrapper; pState->pTdbState->pBackendCfWrapper = pBackendCfWrapper;
stInfo("succ to open state %p on backendWrapper, %p, %s", pState, pBackendCfWrapper, pBackendCfWrapper->idstr); stInfo("succ to open state %p on backendWrapper, %p, %s", pState, pBackendCfWrapper, pBackendCfWrapper->idstr);
inst->pHandle = NULL;
inst->wOpt = NULL;
inst->rOpt = NULL;
inst->cfOpt = NULL;
inst->param = NULL;
return 0; return 0;
} }
taosThreadMutexUnlock(&handle->cfMutex); taosThreadMutexUnlock(&handle->cfMutex);