From: Greg Burri Date: Thu, 22 Sep 2022 09:42:07 +0000 (+0200) Subject: 'Process::memory' returns bytes now. X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=29f7678190211ea660f922f731fcb8993b08cfb9;p=minecraft_web.git 'Process::memory' returns bytes now. --- diff --git a/backend/src/minecraft_controller.rs b/backend/src/minecraft_controller.rs index 451b016..690f3d9 100644 --- a/backend/src/minecraft_controller.rs +++ b/backend/src/minecraft_controller.rs @@ -4,7 +4,7 @@ use chrono::{ DateTime, offset::Local }; #[derive(Clone, Debug)] pub struct MinecraftExe { - memory: u64, // [kB]. + memory: u64, // [B]. load_average_5min: f64, // [%]. uptime: u64, // [s]. world_size: u64, // [B]. @@ -15,7 +15,7 @@ pub struct MinecraftExe { impl MinecraftExe { pub fn format_memory(&self) -> String { - format_byte_size(self.memory * 1024, 2) + format_byte_size(self.memory, 2) } pub fn format_load_average(&self) -> String { @@ -145,7 +145,8 @@ pub fn get_minecraft_executable_information(world_path: &str, backup_path: &str, Some( MinecraftExe { - memory: process.memory() / 3, // Because the Java garbage collector ZGC reports three times more the real memory usage: https://stackoverflow.com/a/62934057/212675 + // 'memory' was divided by 3 but it not necessary any more (the Java garbage collector ZGC reports three times more the real memory usage: https://stackoverflow.com/a/62934057/212675). + memory: process.memory(), load_average_5min: system.load_average().five / system.cpus().len() as f64 * 100., uptime: std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs() - process.start_time(), world_size,