Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] on macOS call systray set_icon will cause memory leak #5382

Open
zangdale opened this issue Oct 10, 2022 · 5 comments
Open

[bug] on macOS call systray set_icon will cause memory leak #5382

zangdale opened this issue Oct 10, 2022 · 5 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@zangdale
Copy link

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:
getlantern/systray#135

@zangdale zangdale added status: needs triage This issue needs to triage, applied to new issues type: bug labels Oct 10, 2022
@zangdale
Copy link
Author

图片

图片

图片

@zangdale zangdale changed the title [bug] on macOS call SetTemplateIcon will cause memory leak [bug] on macOS call systray set_icon will cause memory leak Oct 10, 2022
@paulzql

This comment was marked as off-topic.

@haselkern
Copy link

This is not only limited to set_icon. I'm noticing similar behavior when calling set_title and set_menu.

@dustinblackman
Copy link

dustinblackman commented Jun 1, 2024

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 and haven't found anything so far. I'm wondering if this is happening outside of rust and in the OS bindings instead?

@dustinblackman
Copy link

dustinblackman commented Aug 8, 2024

Digging deeper it looks like this may be the cause:

SSheldon/rust-objc#80

Possible alternative here that may solve this in the future tauri-apps/wry#1239

Specifically for tray icon: tauri-apps/tray-icon#172

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
Status: 📬Proposal
Development

No branches or pull requests

4 participants