update author list in license for (JAL-826)
[jalview.git] / src / jalview / gui / OOMWarning.java
index 3f2b5a8..2195fb2 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)\r
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)\r
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle\r
  * \r
  * This file is part of Jalview.\r
  * \r
@@ -25,6 +25,8 @@ public class OOMWarning implements Runnable
 \r
   String instructions = "";\r
 \r
+  public static boolean oomInprogress = false;\r
+\r
   Component desktop = null;\r
 \r
   /**\r
@@ -40,22 +42,27 @@ public class OOMWarning implements Runnable
   OOMWarning(final String action, final OutOfMemoryError oomex,\r
           final Component instance)\r
   {\r
-    this.action = action;\r
-    desktop = instance;\r
-    if (oomex != null)\r
+    if (!oomInprogress)\r
     {\r
-      if (jalview.bin.Cache.log != null)\r
-      {\r
-        jalview.bin.Cache.log.error("Out of Memory when " + action, oomex);\r
-      }\r
-      else\r
+      oomInprogress = true;\r
+      this.action = action;\r
+      desktop = instance;\r
+      if (oomex != null)\r
       {\r
-        System.err.println("Out of Memory when " + action);\r
-        oomex.printStackTrace();\r
+        if (jalview.bin.Cache.log != null)\r
+        {\r
+          jalview.bin.Cache.log\r
+                  .error("Out of Memory when " + action, oomex);\r
+        }\r
+        else\r
+        {\r
+          System.err.println("Out of Memory when " + action);\r
+          oomex.printStackTrace();\r
+        }\r
       }\r
+      javax.swing.SwingUtilities.invokeLater(this);\r
+      System.gc();\r
     }\r
-    javax.swing.SwingUtilities.invokeLater(this);\r
-    System.gc();\r
   }\r
 \r
   public OOMWarning(String string, OutOfMemoryError oomerror)\r
@@ -74,6 +81,8 @@ public class OOMWarning implements Runnable
                             + "\nSee help files for increasing Java Virtual Machine memory.",\r
                     "Out of memory",\r
                     javax.swing.JOptionPane.WARNING_MESSAGE);\r
+    // hope that there's enough memory left that no more appear.\r
+    oomInprogress = false;\r
   }\r
 \r
 }\r