tauri
tauri copied to clipboard
[bug] on macOS call systray set_icon will cause memory leak
Describe the bug
I want to change the icon on notifications area, I found that each calling method "app.tray_handle().set_icon(tauri::Icon::Raw(include_bytes!("../icons/2.png").to_vec())).unwrap();" will increase memory.
loop {
let icon_row = icons.get(i % icons_len);
if let Some(v) = icon_row {
app.tray_handle().set_icon(v.clone()).unwrap();
} else {
println!("Failed to open the file.");
}
i = i + 1;
if i == icons_len {
i = 0;
}
thread::sleep(ten_millis);
}
Reproduction
Continuous calls “set_icon()”
Expected behavior
No memory leaks
Platform and versions
cargo tauri info
Environment › OS: Mac OS 12.6.0 X64 › Node.js: 16.17.0 › npm: 8.15.0 › pnpm: Not installed! › yarn: 1.22.19 › rustup: 1.25.1 › rustc: 1.63.0 › cargo: 1.63.0 › Rust toolchain: stable-x86_64-apple-darwin
Packages › @tauri-apps/cli [NPM]: 1.1.1 › @tauri-apps/api [NPM]: 1.1.0 › tauri [RUST]: 1.1.1, › tauri-build [RUST]: 1.1.0, › tao [RUST]: 0.14.0, › wry [RUST]: 0.21.1,
App › build-type: bundle › CSP: unset › distDir: ../dist › devPath: http://localhost:1420/ › framework: Vue.js
App directory structure ├─ dist ├─ resources ├─ node_modules ├─ public ├─ runcat.app ├─ src-tauri ├─ .git ├─ .vscode ├─ .idea └─ src
Stack trace
No response
Additional context
Other languages have similar problems: https://github.com/getlantern/systray/issues/135



same issue for me
This is not only limited to set_icon
. I'm noticing similar behavior when calling set_title
and set_menu
.
Currently able to repro on MacOS using Tauri 1.6.7
, where each update I push to my tray adds nearly 1MB of memory that never frees. It's unclear why values passed in to set_icon
+ friends do not properly drop memory after they're replaced. I've dug a bit so far and haven't found anything so far. I'm wondering if this is happening outside of rust and in the OS bindings instead?