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

[HELP] High memory #1732

Closed
PENG-OX opened this issue May 13, 2024 · 1 comment
Closed

[HELP] High memory #1732

PENG-OX opened this issue May 13, 2024 · 1 comment

Comments

@PENG-OX
Copy link

PENG-OX commented May 13, 2024

I tried to use GTK4-rs, the "Hello World" example has more than 100+ memory usage under cargo run --release, is there any way to reduce the memory usage, am I missing some settings?

[package]
name = "gtk_demo1"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gtk4={version = "0.8.2"}
use gtk4::prelude::*;
use gtk4::{glib, Application, ApplicationWindow, Button};

const APP_ID: &str = "org.gtk_rs.HelloWorld2";

fn main() -> glib::ExitCode {
    // Create a new application
    let app = Application::builder().application_id(APP_ID).build();

    // Connect to "activate" signal of `app`
    app.connect_activate(build_ui);

    // Run the application
    app.run()
}

fn build_ui(app: &Application) {
    // Create a button with label and margins
    let button = Button::builder()
        .label("Press me!")
        .margin_top(12)
        .margin_bottom(12)
        .margin_start(12)
        .margin_end(12)
        .build();

    // Connect to "clicked" signal of `button`
    button.connect_clicked(|button| {
        // Set the label to "Hello World!" after the button has been clicked on
        button.set_label("Hello World!");
    });

    // Create a window
    let window = ApplicationWindow::builder()
        .application(app)
        .title("My GTK App")
        .child(&button)
        .build();

    // Present window
    window.present();
}

gtk

@PENG-OX
Copy link
Author

PENG-OX commented May 13, 2024

After setting the local environment variables, the memory is reduced to 33MB

"GSK_RENDERER=cairo"

@PENG-OX PENG-OX closed this as completed May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant