mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-05 06:31:57 -07:00
core: add mallopt to modify trim threshold
This commit is contained in:
@@ -69,6 +69,8 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
using namespace Hyprutils::String;
|
using namespace Hyprutils::String;
|
||||||
using namespace Aquamarine;
|
using namespace Aquamarine;
|
||||||
@@ -162,10 +164,22 @@ void CCompositor::restoreNofile() {
|
|||||||
Debug::log(ERR, "Failed restoring NOFILE limits");
|
Debug::log(ERR, "Failed restoring NOFILE limits");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCompositor::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
|
||||||
|
}
|
||||||
|
|
||||||
CCompositor::CCompositor(bool onlyConfig) : m_bOnlyConfigVerification(onlyConfig), m_iHyprlandPID(getpid()) {
|
CCompositor::CCompositor(bool onlyConfig) : m_bOnlyConfigVerification(onlyConfig), m_iHyprlandPID(getpid()) {
|
||||||
if (onlyConfig)
|
if (onlyConfig)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
setMallocThreshold();
|
||||||
|
|
||||||
m_szHyprTempDataRoot = std::string{getenv("XDG_RUNTIME_DIR")} + "/hypr";
|
m_szHyprTempDataRoot = std::string{getenv("XDG_RUNTIME_DIR")} + "/hypr";
|
||||||
|
|
||||||
if (m_szHyprTempDataRoot.starts_with("/hypr")) {
|
if (m_szHyprTempDataRoot.starts_with("/hypr")) {
|
||||||
|
@@ -52,8 +52,6 @@ class CCompositor {
|
|||||||
void startCompositor();
|
void startCompositor();
|
||||||
void stopCompositor();
|
void stopCompositor();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void createLockFile();
|
|
||||||
void removeLockFile();
|
|
||||||
void bumpNofile();
|
void bumpNofile();
|
||||||
void restoreNofile();
|
void restoreNofile();
|
||||||
|
|
||||||
@@ -163,6 +161,9 @@ class CCompositor {
|
|||||||
void setRandomSplash();
|
void setRandomSplash();
|
||||||
void initManagers(eManagersInitStage stage);
|
void initManagers(eManagersInitStage stage);
|
||||||
void prepareFallbackOutput();
|
void prepareFallbackOutput();
|
||||||
|
void createLockFile();
|
||||||
|
void removeLockFile();
|
||||||
|
void setMallocThreshold();
|
||||||
|
|
||||||
uint64_t m_iHyprlandPID = 0;
|
uint64_t m_iHyprlandPID = 0;
|
||||||
wl_event_source* m_critSigSource = nullptr;
|
wl_event_source* m_critSigSource = nullptr;
|
||||||
|
Reference in New Issue
Block a user