Skip to content
Snippets Groups Projects
Commit d877dc75 authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

ensure giving a chance to display memory error message by garbage collector

parent c8fc306b
Branches
Tags
No related merge requests found
......@@ -114,6 +114,7 @@ public class ApplicationView extends JFrame implements IView<ApplicationControll
// OutOfMermoryError message
private static final String OOME = "<html><body><span style=\"color:red\"><u><big>Salsa encountered a memory error! Unexpected behaviors</big> <i>(freezes, wrong connections, etc.)</i><big> may happen.<br />You should quit and restart Salsa.</u></big></span></body></html>";
private static final String OOME_SIMPLE = "Salsa encountered a memory error!";
private final transient ResourceBundle resourceBundle;
......@@ -356,9 +357,12 @@ public class ApplicationView extends JFrame implements IView<ApplicationControll
// SCAN-915: display a message in case of OutOfMemoryError.
oome = false;
Thread.setDefaultUncaughtExceptionHandler((thread, t) -> {
boolean memory = false;
try {
if (t instanceof OutOfMemoryError) {
memory = (t instanceof OutOfMemoryError);
if (memory) {
oome = true;
System.gc();
SwingUtilities.invokeLater(() -> {
if ((bottomPanel != null) && (bottomPanelLayout != null) && (oomeLabel != null)) {
bottomPanelLayout.show(bottomPanel, OOME_VIEW);
......@@ -366,7 +370,8 @@ public class ApplicationView extends JFrame implements IView<ApplicationControll
});
}
} finally {
LOGGER.error("Uncaugh exception " + t.getClass().getSimpleName() + " in thread " + thread, t);
LOGGER.error(memory ? OOME_SIMPLE
: "Uncaugh exception " + t.getClass().getSimpleName() + " in thread " + thread, t);
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment