Skip to content

Commit

Permalink
core: add mallopt to modify trim threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Feb 9, 2025
1 parent f827dc3 commit 7e18ebc
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Hyprpaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,22 @@
#include <fstream>
#include <signal.h>
#include <sys/types.h>
#include <malloc.h>
#include <unistd.h>

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() = default;
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) {
Expand Down

0 comments on commit 7e18ebc

Please sign in to comment.