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.
30 lines
527 B
Java
30 lines
527 B
Java
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();
|
|
}
|
|
}
|