Skip to content

Instantly share code, notes, and snippets.

@knight-ryu12
Created June 22, 2016 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knight-ryu12/319c3dc1abf911565e9bf664130a92c5 to your computer and use it in GitHub Desktop.
Save knight-ryu12/319c3dc1abf911565e9bf664130a92c5 to your computer and use it in GitHub Desktop.
Thread GCThread = new Thread(() -> {
long CurrentMem = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory() / (1024 * 1024));
System.gc();
CurrentMem = CurrentMem - (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory() / (1024 * 1024));
logger.info("GC executed. Freed Memory " + CurrentMem+"MB");
try{
Thread.sleep(Long.parseLong(configuration.getProperty("GCTime")));
} catch (InterruptedException e) {
e.printStackTrace();
}
//logger.info("GC executed. Freed Memory " + CurrentMem);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment