Skip to content

is it possible to get the memory usage of the running application process or is the one from example retrieving its usage? #1086

Answered by GuillaumeGomez
Cariaga asked this question in Q&A
Discussion options

You must be logged in to vote

Yes you can by doing:

use sysinfo::{get_current_pid, ProcessExt, System, SystemExt};

if let Ok(pid) = get_current_pid() {
    let mut system = System::new_all();
    if let Some(p) = system.process(pid) {
        println!("{pid:?} uses {} bytes", p.memory());
    }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@GuillaumeGomez
Comment options

Answer selected by GuillaumeGomez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants