Limit malloc_trim to once per second

This commit is contained in:
Ilya Fedin
2025-07-20 14:24:32 +00:00
committed by John Preston
parent 1c35a91d13
commit e070af3163

View File

@@ -176,7 +176,18 @@ LinuxIntegration::LinuxIntegration()
QObject::connect(
QCoreApplication::eventDispatcher(),
&QAbstractEventDispatcher::aboutToBlock,
[] { malloc_trim(0); });
[] {
static auto timer = [] {
QElapsedTimer timer;
timer.start();
return timer;
}();
if (timer.hasExpired(1000)) {
malloc_trim(0);
timer.start();
}
});
#endif // __GLIBC__
}