You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Howdy! I was using your crate to send mach messages with system stats to Sketchybar (Simple Sketchybar System Stats). I noticed that over time, the memory usage kept slowly growing.
I believe the main culprit is that the response pointer isn't freed after each message:
let result = unsafe{CStr::from_ptr(sketchybar(command.into_raw(), bar_name.into_raw())).to_string_lossy().into_owned()};Ok(result)
However, I'm no Rust or C expert (this is my first app using either language), so I iterated and tried different solutions to reduce the memory and port usage in my own implementation.
I ended up adding a C function to sketchybar.h to call from the Rust side to free the response pointer:
Some of my modifications are specific to my use case (I'm sending lots of messages, however I'm not expecting to receive messages), and I wanted to refresh the mach ports periodically because I had an issue with stale response ports not always being deallocated, so my function is async. I also haave a cleanup function in case my app is stopped but Sketchybar continues running.
The text was updated successfully, but these errors were encountered:
Howdy! I was using your crate to send mach messages with system stats to Sketchybar (Simple Sketchybar System Stats). I noticed that over time, the memory usage kept slowly growing.
I believe the main culprit is that the response pointer isn't freed after each message:
However, I'm no Rust or C expert (this is my first app using either language), so I iterated and tried different solutions to reduce the memory and port usage in my own implementation.
I ended up adding a C function to
sketchybar.h
to call from the Rust side to free the response pointer:I don't know if you've noticed a similar issue with memory usage, but I'm sharing my implementation in case it's helpful:
sketchybar.rs
sketchybar.h
Some of my modifications are specific to my use case (I'm sending lots of messages, however I'm not expecting to receive messages), and I wanted to refresh the mach ports periodically because I had an issue with stale response ports not always being deallocated, so my function is async. I also haave a cleanup function in case my app is stopped but Sketchybar continues running.
The text was updated successfully, but these errors were encountered: