Merge pull request #1564 from taosdata/hotfix/mem_leak

fix part of mem-leak
This commit is contained in:
slguan 2020-04-09 15:47:56 +08:00 committed by GitHub
commit 775c89386b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 4 deletions

View File

@ -141,7 +141,7 @@ STSchema *tdDupSchema(STSchema *pSchema) {
* Free the SSchema object created by tdNewSchema or tdDupSchema * Free the SSchema object created by tdNewSchema or tdDupSchema
*/ */
void tdFreeSchema(STSchema *pSchema) { void tdFreeSchema(STSchema *pSchema) {
if (pSchema == NULL) free(pSchema); if (pSchema != NULL) free(pSchema);
} }
/** /**

View File

@ -25,6 +25,7 @@
#include "dataformat.h" #include "dataformat.h"
#include "vnode.h" #include "vnode.h"
#include "vnodeInt.h" #include "vnodeInt.h"
#include "tutil.h"
static int32_t (*vnodeProcessWriteMsgFp[TSDB_MSG_TYPE_MAX])(SVnodeObj *, void *, SRspRet *); static int32_t (*vnodeProcessWriteMsgFp[TSDB_MSG_TYPE_MAX])(SVnodeObj *, void *, SRspRet *);
static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pMsg, SRspRet *); static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pMsg, SRspRet *);
@ -157,6 +158,8 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe
void *pTsdb = vnodeGetTsdb(pVnode); void *pTsdb = vnodeGetTsdb(pVnode);
code = tsdbCreateTable(pTsdb, &tCfg); code = tsdbCreateTable(pTsdb, &tCfg);
tfree(pDestSchema);
dTrace("pVnode:%p vgId:%d, table:%s is created, result:%x", pVnode, pVnode->vgId, pTable->tableId, code); dTrace("pVnode:%p vgId:%d, table:%s is created, result:%x", pVnode, pVnode->vgId, pTable->tableId, code);
return code; return code;
} }

View File

@ -62,6 +62,7 @@ STsdbFileH *tsdbInitFileH(char *dataDir, int maxFiles) {
// TODO // TODO
} }
} }
closedir(dir);
return pFileH; return pFileH;
} }

View File

@ -268,6 +268,9 @@ int32_t tsdbCloseRepo(tsdb_repo_t *repo) {
tsdbFreeCache(pRepo->tsdbCache); tsdbFreeCache(pRepo->tsdbCache);
tfree(pRepo->rootDir);
tfree(pRepo);
return 0; return 0;
} }
@ -847,6 +850,7 @@ static void *tsdbCommitData(void *arg) {
tsdbLockRepo(arg); tsdbLockRepo(arg);
tdListMove(pCache->imem->list, pCache->pool.memPool); tdListMove(pCache->imem->list, pCache->pool.memPool);
tdListFree(pCache->imem->list);
free(pCache->imem); free(pCache->imem);
pCache->imem = NULL; pCache->imem = NULL;
pRepo->commit = 0; pRepo->commit = 0;
@ -1125,11 +1129,11 @@ static int tsdbWriteBlockToFileImpl(SFile *pFile, SDataCols *pCols, int pointsTo
*len += pCompCol->len; *len += pCompCol->len;
} }
if (pCompData == NULL) free((void *)pCompData); tfree(pCompData);
return 0; return 0;
_err: _err:
if (pCompData == NULL) free((void *)pCompData); tfree(pCompData);
return -1; return -1;
} }

View File

@ -312,6 +312,14 @@ int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId) {
// return 0; // return 0;
// } // }
static void tsdbFreeMemTable(SMemTable *pMemTable) {
if (pMemTable) {
tSkipListDestroy(pMemTable->pData);
}
free(pMemTable);
}
static int tsdbFreeTable(STable *pTable) { static int tsdbFreeTable(STable *pTable) {
// TODO: finish this function // TODO: finish this function
if (pTable->type == TSDB_CHILD_TABLE) { if (pTable->type == TSDB_CHILD_TABLE) {
@ -323,7 +331,10 @@ static int tsdbFreeTable(STable *pTable) {
// Free content // Free content
if (TSDB_TABLE_IS_SUPER_TABLE(pTable)) { if (TSDB_TABLE_IS_SUPER_TABLE(pTable)) {
tSkipListDestroy(pTable->pIndex); tSkipListDestroy(pTable->pIndex);
} }
tsdbFreeMemTable(pTable->mem);
tsdbFreeMemTable(pTable->imem);
free(pTable); free(pTable);
return 0; return 0;

View File

@ -177,6 +177,7 @@ void tsdbCloseMetaFile(SMetaFile *mfh) {
close(mfh->fd); close(mfh->fd);
taosHashCleanup(mfh->map); taosHashCleanup(mfh->map);
tfree(mfh);
} }
static int32_t tsdbGetMetaFileName(char *rootDir, char *fname) { static int32_t tsdbGetMetaFileName(char *rootDir, char *fname) {