From 1d157152c12f0b28bf729a241eaa74dc8cebf2cf Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 19 May 2016 09:47:33 +0200 Subject: [PATCH] IDEA-156259 idea.log spammed by "PerformanceWatcher - High memory usage" --- .../com/intellij/diagnostic/PerformanceWatcher.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/platform/core-impl/src/com/intellij/diagnostic/PerformanceWatcher.java b/platform/core-impl/src/com/intellij/diagnostic/PerformanceWatcher.java index e516d80eff30..306682229cbf 100644 --- a/platform/core-impl/src/com/intellij/diagnostic/PerformanceWatcher.java +++ b/platform/core-impl/src/com/intellij/diagnostic/PerformanceWatcher.java @@ -292,12 +292,13 @@ public class PerformanceWatcher implements ApplicationComponent { } private static void checkMemoryUsage(File file) { - final Runtime rt = Runtime.getRuntime(); - final long allocatedMem = rt.maxMemory(); - final long unusedMem = rt.freeMemory(); - if (unusedMem < allocatedMem / 5) { - LOG.info("High memory usage (free " + unusedMem / 1024 / 1024 + - " of " + allocatedMem / 1024 / 1024 + + Runtime rt = Runtime.getRuntime(); + long maxMemory = rt.maxMemory(); + long usedMemory = rt.totalMemory() - rt.freeMemory(); + long freeMemory = maxMemory - usedMemory; + if (freeMemory < maxMemory / 5) { + LOG.info("High memory usage (free " + freeMemory / 1024 / 1024 + + " of " + maxMemory / 1024 / 1024 + " MB) while dumping threads to " + file); } }