trigger garbage collection periodically

This reduces the memory usage, because the old generation can be made
smaller and we don't have to wait until max heap usage has been reached.
This commit is contained in:
2017-09-23 10:54:28 +02:00
parent 9e3dd27eb0
commit b7dc22275d

View File

@@ -1,10 +1,29 @@
package org.lucares.pdbui;
import java.util.concurrent.TimeUnit;
import org.springframework.boot.SpringApplication;
public class PdbWebapp {
public static void main(final String[] args) throws Exception {
SpringApplication.run(MySpringConfiguration.class, args);
Thread t = new Thread(()-> {
while(true){
try{
TimeUnit.MINUTES.sleep(10);
}catch(InterruptedException e)
{
// ignore
}
System.gc();
}
});
t.setDaemon(true);
t.setName("periodic-gc");
t.start();
}
}