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; }