1 package org.matsim.utils;
3 import org.apache.logging.log4j.LogManager;
4 import org.apache.logging.log4j.Logger;
6 import java.util.concurrent.atomic.AtomicBoolean;
18 public static void start(
int interval_seconds) {
19 startMillis(interval_seconds * 1000L);
22 static void startMillis(
long interval) {
26 thread =
new Thread(runnable,
"MemoryPrinter");
27 thread.setDaemon(
true);
31 public static void stop() {
39 long totalMem = Runtime.getRuntime().totalMemory();
40 long freeMem = Runtime.getRuntime().freeMemory();
41 long usedMem = totalMem - freeMem;
42 LOG.info(
"used RAM: " + (usedMem/1024/1024) +
" MB free: " + (freeMem/1024/1024) +
" MB total: " + (totalMem/1024/1024) +
" MB");
48 private final AtomicBoolean
stopFlag =
new AtomicBoolean(
false);
59 Thread.sleep(this.millis);
60 }
catch (InterruptedException e) {
61 if (this.stopFlag.get()) {
static void printMemory()
static MemoryPrinter runnable
final AtomicBoolean stopFlag
static void start(int interval_seconds)
MemoryPrinter(long millis)