memory leak

This commit is contained in:
liuyao 2023-04-18 09:50:13 +08:00
parent 47bf2374db
commit 5460eaf29a
1 changed files with 11 additions and 2 deletions

View File

@ -100,6 +100,14 @@ void destroyRowBuffPosPtr(void* ptr) {
} }
} }
void destroyRowBuffAllPosPtr(void* ptr) {
if (!ptr) {
return;
}
SRowBuffPos* pPos = *(SRowBuffPos**)ptr;
destroyRowBuffPos(pPos);
}
void destroyRowBuff(void* ptr) { void destroyRowBuff(void* ptr) {
if (!ptr) { if (!ptr) {
return; return;
@ -111,7 +119,7 @@ void streamFileStateDestroy(SStreamFileState* pFileState) {
if (!pFileState) { if (!pFileState) {
return; return;
} }
tdListFreeP(pFileState->usedBuffs, destroyRowBuffPosPtr); tdListFreeP(pFileState->usedBuffs, destroyRowBuffAllPosPtr);
tdListFreeP(pFileState->freeBuffs, destroyRowBuff); tdListFreeP(pFileState->freeBuffs, destroyRowBuff);
tSimpleHashCleanup(pFileState->rowBuffMap); tSimpleHashCleanup(pFileState->rowBuffMap);
taosMemoryFree(pFileState); taosMemoryFree(pFileState);
@ -443,7 +451,8 @@ int32_t recoverSnapshot(SStreamFileState* pFileState) {
code = streamStateGetKVByCur_rocksdb(pCur, pNewPos->pKey, (const void**)&pVal, &pVLen); code = streamStateGetKVByCur_rocksdb(pCur, pNewPos->pKey, (const void**)&pVal, &pVLen);
if (code != TSDB_CODE_SUCCESS || pFileState->getTs(pNewPos->pKey) < pFileState->flushMark) { if (code != TSDB_CODE_SUCCESS || pFileState->getTs(pNewPos->pKey) < pFileState->flushMark) {
destroyRowBuffPos(pNewPos); destroyRowBuffPos(pNewPos);
tdListPopTail(pFileState->usedBuffs); SListNode* pNode = tdListPopTail(pFileState->usedBuffs);
taosMemoryFreeClear(pNode);
break; break;
} }
memcpy(pNewPos->pRowBuff, pVal, pVLen); memcpy(pNewPos->pRowBuff, pVal, pVLen);