Merge pull request #17762 from taosdata/fix/memReturn

enh: return mem to os
This commit is contained in:
Shengliang Guan 2022-10-31 20:12:22 +08:00 committed by GitHub
commit 8cdbcb89f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -36,6 +36,7 @@ void *taosMemoryStrDup(const char *ptr);
void taosMemoryFree(void *ptr); void taosMemoryFree(void *ptr);
int64_t taosMemorySize(void *ptr); int64_t taosMemorySize(void *ptr);
void taosPrintBackTrace(); void taosPrintBackTrace();
void taosMemoryTrim(int32_t size);
#define taosMemoryFreeClear(ptr) \ #define taosMemoryFreeClear(ptr) \
do { \ do { \

View File

@ -28,6 +28,7 @@ static void *dmStatusThreadFp(void *param) {
int64_t curTime = taosGetTimestampMs(); int64_t curTime = taosGetTimestampMs();
float interval = (curTime - lastTime) / 1000.0f; float interval = (curTime - lastTime) / 1000.0f;
if (interval >= tsStatusInterval) { if (interval >= tsStatusInterval) {
taosMemoryTrim(0);
dmSendStatusReq(pMgmt); dmSendStatusReq(pMgmt);
lastTime = curTime; lastTime = curTime;
} }

View File

@ -336,3 +336,12 @@ int64_t taosMemorySize(void *ptr) {
#endif #endif
#endif #endif
} }
void taosMemoryTrim(int32_t size) {
#if defined(WINDOWS) || defined(DARWIN)
// do nothing
return;
#else
malloc_trim(size);
#endif
}