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(); }