core: add mallopt to modify trim threshold

This commit is contained in:
Vaxry 2025-02-09 17:40:50 +00:00 committed by y0usaf
parent bf38a16940
commit 5286277663

View file

@ -3,10 +3,23 @@
#include <fstream>
#include <signal.h>
#include <sys/types.h>
#include "helpers/RandomGenerator.hpp"
#include <malloc.h>
#include <unistd.h>
#include "helpers/ImagePicker.hpp"
CHyprpaper::CHyprpaper() = default;
static void setMallocThreshold() {
#ifdef M_TRIM_THRESHOLD
// The default is 128 pages,
// which is very large and can lead to a lot of memory used for no reason
// because trimming hasn't happened
static const int PAGESIZE = sysconf(_SC_PAGESIZE);
mallopt(M_TRIM_THRESHOLD, 6 * PAGESIZE);
#endif
}
CHyprpaper::CHyprpaper() {
setMallocThreshold();
}
static void handleGlobal(CCWlRegistry* registry, uint32_t name, const char* interface, uint32_t version) {
if (strcmp(interface, wl_compositor_interface.name) == 0) {