mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-24 06:22:59 +02:00
Limit the amount of malloc arenas and call malloc_trim periodically with glibc
To prevent excessive memory usage looking like memory leak
This commit is contained in:
parent
ef69796798
commit
77642d2876
1 changed files with 12 additions and 0 deletions
|
@ -22,6 +22,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <gio/gio.hpp>
|
||||
#include <xdpinhibit/xdpinhibit.hpp>
|
||||
|
||||
#ifdef __GLIBC__
|
||||
#include <malloc.h>
|
||||
#endif // __GLIBC__
|
||||
|
||||
namespace Platform {
|
||||
namespace {
|
||||
|
||||
|
@ -166,6 +170,14 @@ LinuxIntegration::LinuxIntegration()
|
|||
g_warning("Qt is running without GLib event loop integration, "
|
||||
"expect various functionality to not to work.");
|
||||
}
|
||||
|
||||
#ifdef __GLIBC__
|
||||
mallopt(M_ARENA_MAX, 1);
|
||||
QObject::connect(
|
||||
QCoreApplication::eventDispatcher(),
|
||||
&QAbstractEventDispatcher::aboutToBlock,
|
||||
[] { malloc_trim(0); });
|
||||
#endif // __GLIBC__
|
||||
}
|
||||
|
||||
void LinuxIntegration::init() {
|
||||
|
|
Loading…
Add table
Reference in a new issue