Skip to content

Commit

Permalink
fix: set M_MALLOC_THRESHOLD to prevent malloc from hoarding memory
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed Feb 4, 2025
1 parent 726c828 commit f5adf43
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cosmic-applets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ cosmic-applet-time = { path = "../cosmic-applet-time" }
cosmic-applet-workspaces = { path = "../cosmic-applet-workspaces" }
cosmic-applet-input-sources = { path = "../cosmic-applet-input-sources" }
cosmic-panel-button = { path = "../cosmic-panel-button" }
libc = "0.2"
libcosmic.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
Expand Down
9 changes: 8 additions & 1 deletion cosmic-applets/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
const VERSION: &str = env!("CARGO_PKG_VERSION");

fn main() -> cosmic::iced::Result {
// Prevents glibc from hoarding memory, such as cosmic-applet-minimize
// consuming 100s of megabytes on restoring a minimized window.
#[cfg(target_os = "linux")]
unsafe {
libc::mallopt(libc::M_MMAP_THRESHOLD, 65536);
}

tracing_subscriber::fmt().with_env_filter("warn").init();
let _ = tracing_log::LogTracer::init();

Expand Down Expand Up @@ -32,6 +39,6 @@ fn main() -> cosmic::iced::Result {
"cosmic-applet-workspaces" => cosmic_applet_workspaces::run(),
"cosmic-applet-input-sources" => cosmic_applet_input_sources::run(),
"cosmic-panel-button" => cosmic_panel_button::run(),
_ => return Ok(()),
_ => Ok(()),
}
}

0 comments on commit f5adf43

Please sign in to comment.