Skip to content

Commit 7ece3f9

Browse files
committed
fix: set M_MALLOC_THRESHOLD to prevent memory fragmentation
1 parent 726c828 commit 7ece3f9

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cosmic-applets/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ cosmic-applet-time = { path = "../cosmic-applet-time" }
2020
cosmic-applet-workspaces = { path = "../cosmic-applet-workspaces" }
2121
cosmic-applet-input-sources = { path = "../cosmic-applet-input-sources" }
2222
cosmic-panel-button = { path = "../cosmic-panel-button" }
23+
libc = "0.2"
2324
libcosmic.workspace = true
2425
tracing.workspace = true
2526
tracing-subscriber.workspace = true

cosmic-applets/src/main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
const VERSION: &str = env!("CARGO_PKG_VERSION");
55

66
fn main() -> cosmic::iced::Result {
7+
// Prevents glibc from hoarding memory, such as cosmic-applet-minimize
8+
// consuming 100s of megabytes on restoring a minimized window.
9+
#[cfg(target_os = "linux")]
10+
unsafe {
11+
libc::mallopt(libc::M_MMAP_THRESHOLD, 65536);
12+
}
13+
714
tracing_subscriber::fmt().with_env_filter("warn").init();
815
let _ = tracing_log::LogTracer::init();
916

@@ -32,6 +39,6 @@ fn main() -> cosmic::iced::Result {
3239
"cosmic-applet-workspaces" => cosmic_applet_workspaces::run(),
3340
"cosmic-applet-input-sources" => cosmic_applet_input_sources::run(),
3441
"cosmic-panel-button" => cosmic_panel_button::run(),
35-
_ => return Ok(()),
42+
_ => Ok(()),
3643
}
3744
}

0 commit comments

Comments
 (0)