X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fnet%2Fsf%2Fopenrocket%2Fgui%2Fmain%2FExceptionHandler.java;h=8496ad5be57f6400d37d986a2f4764e54a999412;hb=e298a9509613f232227d16d28310611b33c3aa03;hp=7b233b022b764c03d0771145411b169f76d781ab;hpb=b3c3c1071dfdca4c6b3eb9935dc461201abdaf60;p=debian%2Fopenrocket diff --git a/src/net/sf/openrocket/gui/main/ExceptionHandler.java b/src/net/sf/openrocket/gui/main/ExceptionHandler.java index 7b233b02..8496ad5b 100644 --- a/src/net/sf/openrocket/gui/main/ExceptionHandler.java +++ b/src/net/sf/openrocket/gui/main/ExceptionHandler.java @@ -12,8 +12,10 @@ public class ExceptionHandler implements Thread.UncaughtExceptionHandler { /** * A memory reserve of 0.5 MB of memory, that can be freed when showing the dialog. + *
+ * This field is package-private so that the JRE cannot optimize its use away.
*/
- private static volatile byte[] memoryReserve = null;
+ static volatile byte[] memoryReserve = null;
private static ExceptionHandler instance = null;
@@ -27,7 +29,7 @@ public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
public void uncaughtException(final Thread t, final Throwable e) {
// Free memory reserve if out of memory
- if (e instanceof OutOfMemoryError) {
+ if (isOutOfMemoryError(e)) {
memoryReserve = null;
handling = false;
}
@@ -137,11 +139,11 @@ public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
private void showDialog(Thread t, Throwable e) {
// Out of memory
- if (e instanceof OutOfMemoryError) {
+ if (isOutOfMemoryError(e)) {
JOptionPane.showMessageDialog(null,
new Object[] {
- "Out of memory!",
- "You should immediately close unnecessary design windows,
" +
+ "OpenRocket can out of available memory!",
+ "You should immediately close unnecessary design windows,",
"save any unsaved designs and restart OpenRocket!"
}, "Out of memory", JOptionPane.ERROR_MESSAGE);
return;
@@ -163,7 +165,7 @@ public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
// Normal exception, show question dialog
String msg = e.getClass().getSimpleName() + ": " + e.getMessage();
if (msg.length() > 90) {
- msg = msg.substring(0, 90) + "...";
+ msg = msg.substring(0, 80) + "...";
}
@@ -210,6 +212,9 @@ public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
}
+ /**
+ * Reserve the buffer memory that is freed in case an OutOfMemoryError occurs.
+ */
private static void reserveMemory() {
memoryReserve = new byte[MEMORY_RESERVE];
for (int i=0; i