From ea2bbfb5c1721c345910d010d67c689970241011 Mon Sep 17 00:00:00 2001 From: John Sully Date: Wed, 7 Apr 2021 17:30:59 +0000 Subject: [PATCH] Fix issue where GC is not free'd until a BGSAVE Former-commit-id: 38523e6b508cf5f4b40c178dfe98554abea8f6bd --- src/server.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/server.cpp b/src/server.cpp index bbee218ac..6d297c937 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2450,6 +2450,16 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { g_pserver->ilockRingHead = 0; }); + run_with_period(10) { + // Server threads don't free the GC, but if we don't have a + // a bgsave or some other async task then we'll hold onto the + // data for too long + g_pserver->asyncworkqueue->AddWorkFunction([]{ + auto epoch = g_pserver->garbageCollector.startEpoch(); + g_pserver->garbageCollector.endEpoch(epoch); + }); + } + g_pserver->cronloops++; return 1000/g_pserver->hz; }