gc: better logging

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5578 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
borg-0300 16 years ago
parent b1f9c00118
commit b19bc611b0

@ -25,6 +25,7 @@
package de.anomic.kelondro.util; package de.anomic.kelondro.util;
import de.anomic.tools.Formatter;
/** /**
* Use this to get information about memory usage or try to free some memory * Use this to get information about memory usage or try to free some memory
@ -47,12 +48,17 @@ public class MemoryControl {
public final synchronized static void gc(final int last, final String info) { // thq public final synchronized static void gc(final int last, final String info) { // thq
final long elapsed = System.currentTimeMillis() - lastGC; final long elapsed = System.currentTimeMillis() - lastGC;
if (elapsed > last) { if (elapsed > last) {
final long free = free(); final long before = free();
//System.out.println("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"); //System.out.println("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
final long start = System.currentTimeMillis();
System.gc(); System.gc();
//System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ if you see this many times please report to forum"); //System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ if you see this many times please report to forum");
lastGC = System.currentTimeMillis(); lastGC = System.currentTimeMillis();
if (log.isFine()) log.logInfo("[gc] before: " + free + ", after: " + free() + ", call: " + info); final long after = free();
if (log.isFine()) log.logInfo("[gc] before: " + Formatter.bytesToString(before) +
", after: " + Formatter.bytesToString(after) +
", freed: " + Formatter.bytesToString(after - before) +
", rt: " + (lastGC - start) + " ms, call: " + info);
} else if (log.isFine()) { } else if (log.isFine()) {
if (log.isFinest()) log.logFinest("[gc] no execute, last run: " + (elapsed / 1000) + " seconds ago, call: " + info); if (log.isFinest()) log.logFinest("[gc] no execute, last run: " + (elapsed / 1000) + " seconds ago, call: " + info);
} }
@ -173,7 +179,7 @@ public class MemoryControl {
public static long used() { public static long used() {
return total() - free(); return total() - free();
} }
/** /**
* main * main
* @param args * @param args

Loading…
Cancel
Save