From 41334fa33ec58ccc28b04e004afa03dc2fc6868e Mon Sep 17 00:00:00 2001 From: InspurSDN Date: Thu, 4 Jul 2024 16:38:37 +0800 Subject: [PATCH] after apply_view, use malloc_trim to release memory to system why I did: after warm-reboot with all vlan members, syncd use memory up to 1.8g, and can not reduce to its normal state. what I did: this come from the glibc behavior, in the main heap, it almost not release memory to system, in apply view, huge memory used for compare logic, and do not use it again. so I add malloc_trim to release it. --- syncd/Syncd.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/syncd/Syncd.cpp b/syncd/Syncd.cpp index 980886f8f..7baeb6c4d 100644 --- a/syncd/Syncd.cpp +++ b/syncd/Syncd.cpp @@ -36,6 +36,8 @@ #include #include +#include + #define DEF_SAI_WARM_BOOT_DATA_FILE "/var/warmboot/sai-warmboot.bin" #define SAI_FAILURE_DUMP_SCRIPT "/usr/bin/sai_failure_dump.sh" @@ -3872,6 +3874,7 @@ sai_status_t Syncd::processNotifySyncd( try { status = applyView(); + (void)malloc_trim(0); } catch(...) {