Skip to content

Commit

Permalink
call malloc trim
Browse files Browse the repository at this point in the history
Signed-off-by: Lawrence Lee <[email protected]>
  • Loading branch information
theasianpianist committed Jan 13, 2025
1 parent b0a1021 commit 5451955
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions common/notificationconsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <iostream>
#include <deque>
#include <malloc.h>
#include "redisapi.h"

#define NOTIFICATION_SUBSCRIBE_TIMEOUT (1000)
Expand Down Expand Up @@ -167,6 +168,15 @@ void swss::NotificationConsumer::pop(std::string &op, std::string &data, std::ve
* Force the memory to be released by destroying existing queue and creating a new one.
*/
SWSS_LOG_INFO("%s queue is empty, recreating", m_channel.c_str());
int rv = malloc_trim(0);
if (rv == 1)
{
SWSS_LOG_INFO("Memory released successfully");
}
else
{
SWSS_LOG_INFO("No memory released by malloc_trim");
}
m_queue.reset();
m_queue = nullptr;
m_queue = std::make_shared<std::queue<std::string>>();
Expand Down

0 comments on commit 5451955

Please sign in to comment.