From f52000d86eed69ae8c96b7199b208a0a0a150f68 Mon Sep 17 00:00:00 2001 From: gccgdb1234 Date: Sat, 29 Oct 2022 22:25:40 +0800 Subject: [PATCH] return mem to os --- include/os/osMemory.h | 1 + source/dnode/mgmt/mgmt_dnode/src/dmWorker.c | 3 ++- source/os/src/osMemory.c | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/os/osMemory.h b/include/os/osMemory.h index 7ec8366ee4..14d53a7a06 100644 --- a/include/os/osMemory.h +++ b/include/os/osMemory.h @@ -36,6 +36,7 @@ void *taosMemoryStrDup(const char *ptr); void taosMemoryFree(void *ptr); int64_t taosMemorySize(void *ptr); void taosPrintBackTrace(); +void taosMemoryTrim(int32_t size); #define taosMemoryFreeClear(ptr) \ do { \ diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c index ca8a434d05..07a612bb35 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c @@ -20,7 +20,7 @@ static void *dmStatusThreadFp(void *param) { SDnodeMgmt *pMgmt = param; int64_t lastTime = taosGetTimestampMs(); setThreadName("dnode-status"); - + while (1) { taosMsleep(200); if (pMgmt->pData->dropped || pMgmt->pData->stopped) break; @@ -28,6 +28,7 @@ static void *dmStatusThreadFp(void *param) { int64_t curTime = taosGetTimestampMs(); float interval = (curTime - lastTime) / 1000.0f; if (interval >= tsStatusInterval) { + taosMemoryTrim(0); dmSendStatusReq(pMgmt); lastTime = curTime; } diff --git a/source/os/src/osMemory.c b/source/os/src/osMemory.c index 75a963d5c7..2949d08d61 100644 --- a/source/os/src/osMemory.c +++ b/source/os/src/osMemory.c @@ -336,3 +336,7 @@ int64_t taosMemorySize(void *ptr) { #endif #endif } + +void taosMemoryTrim(int32_t size) { + malloc_trim(size); +}