Issue #288 Garbage collection often

This commit is contained in:
Jindra Pet��k
2013-08-20 19:55:58 +02:00
parent 38c144c2ba
commit 2998b0279a
@@ -51,9 +51,7 @@ import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Scanner;
import java.util.logging.ConsoleHandler;
@@ -68,7 +66,6 @@ import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.filechooser.FileFilter;
/**
@@ -561,9 +558,9 @@ public class Main {
}
public static void initLang() {
if (Configuration.containsConfig("locale")) {
if (Configuration.containsConfig("locale")) {
Locale.setDefault(Locale.forLanguageTag((String) Configuration.getConfig("locale", "en")));
}
}
UIManager.put("OptionPane.okButtonText", AppStrings.translate("button.ok"));
UIManager.put("OptionPane.yesButtonText", AppStrings.translate("button.yes"));
UIManager.put("OptionPane.noButtonText", AppStrings.translate("button.no"));
@@ -648,12 +645,31 @@ public class Main {
UIManager.put("FileChooser.folderNameLabelText", AppStrings.translate("FileChooser.folderNameLabelText"));
}
/**
* This may help to free some memory when not needed (maybe?)
*/
private static void startFreeMemThread() {
new Thread() {
@Override
public void run() {
try {
while (true) {
Thread.sleep(5000);
System.gc();
}
} catch (InterruptedException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}.start();
}
/**
* @param args the command line arguments
* @throws IOException
*/
public static void main(String[] args) throws IOException {
startFreeMemThread();
loadProperties();
Configuration.loadFromFile(getConfigFile(), getReplacementsFile());
int pos = 0;