timvisee / lazymc

💤 Put your Minecraft server to rest when idle.
GNU General Public License v3.0
552 stars 14 forks source link

How to get the advertised ram usage? #67

Open thisRedH opened 3 months ago

thisRedH commented 3 months ago

I dont know how to get the advertised 3kb ram usage and also dont see how this is possible considering you are using tokio. I tested this using the sysinfo (0.30.8) crate and added these lines to src/service/server in fn service.

tokio::spawn(async {
    let mut system = sysinfo::System::new_all();
    let pid = sysinfo::get_current_pid().unwrap();
    loop {
        system.refresh_all();

        if let Some(process) = system.process(pid) {
            println!(
                "phisical {} kb, {} mb ; virtual {} kb, {} mb",
                process.memory() / 1000,
                process.memory() / 1000_000,
                process.virtual_memory() / 1000,
                process.virtual_memory() / 1000_000
            );
        } else {
            println!("Failed to get process information.");
        }
        tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
    }
});

(compiled using cargo b --release)

Now dont get me wrong 3mb is extremly little ram, but still it isnt 3kb. Am i doing something wrong or may there be a Typo in the README?