From c8fb4ffde1111cf9a898782589321ddfd97a6a93 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 17 Jun 2023 11:47:12 +0200 Subject: [PATCH] Add some debug infos Signed-off-by: yoyosource --- .../bausystem/features/world/RamUsage.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/RamUsage.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/RamUsage.java index 711a574c..17b632cc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/RamUsage.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/RamUsage.java @@ -28,16 +28,28 @@ public class RamUsage { private File meminfo = new File("/proc/meminfo"); + private double usageSelf = 0D; private double usage = 0D; private double load = 0D; + public static void init() { + } + static { Thread thread = new Thread(() -> { while (true) { + long maxMemory = Runtime.getRuntime().maxMemory(); + long totalMemory = Runtime.getRuntime().totalMemory(); + long freeMemory = Runtime.getRuntime().freeMemory(); + long usedMemory = totalMemory - freeMemory; + usageSelf = usedMemory / (double) totalMemory; + double usageSelfByMax = usedMemory / (double) maxMemory; + System.out.println("Self: " + usageSelf + "/" + usageSelfByMax + /* " " + maxMemory + " " + totalMemory + " " + freeMemory + " " + usedMemory + */ " Ram: " + usage + " CPU: " + load); + usage = _getUsage(); load = _getLoad(); try { - Thread.sleep(1000); + Thread.sleep(2000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); }