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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user