Adjust the reported memory from the java process.
[minecraft_web.git] / backend / src / minecraft_controller.rs
index 9287cda..7af13dd 100644 (file)
@@ -89,7 +89,7 @@ fn get_status_from_rcon(rcon_password: &str) -> StatusFromRcon {
                             Ok(resp) =>\r
                                 match resp.body.find(':') {\r
                                     Some(i) if i < resp.body.len() -1 =>\r
-                                        resp.body[i + 1..resp.body.len() - 1]\r
+                                        resp.body[i + 1..resp.body.len()]\r
                                             .split(',')\r
                                             .map(|nick| nick.trim().to_string())\r
                                             .filter(|nick| !nick.is_empty())\r
@@ -144,7 +144,7 @@ pub fn get_minecraft_executable_information(world_path: &str, backup_path: &str,
 \r
         Some(\r
             MinecraftExe {\r
-                memory: process.memory(),\r
+                memory: process.memory() / 3, // Because the Java garbage collector ZGC reports three times more the real memory usage: https://stackoverflow.com/a/62934057/212675\r
                 load_average_5min: system.get_load_average().five / system.get_processors().len() as f64 * 100.,\r
                 uptime: std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs() - process.start_time(),\r
                 world_size,\r