use OOMwarning to warn user when out of Memory occurs
authorjprocter <Jim Procter>
Fri, 29 Aug 2008 11:04:33 +0000 (11:04 +0000)
committerjprocter <Jim Procter>
Fri, 29 Aug 2008 11:04:33 +0000 (11:04 +0000)
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/AppJmol.java
src/jalview/gui/PCAPanel.java
src/jalview/gui/SeqCanvas.java
src/jalview/gui/SequenceFetcher.java
src/jalview/ws/DBRefFetcher.java
src/jalview/ws/WSThread.java

index 1320aa0..3aa69f1 100755 (executable)
@@ -1408,20 +1408,7 @@ public class AlignFrame
     }
     catch (OutOfMemoryError er)
     {
-      er.printStackTrace();
-      javax.swing.SwingUtilities.invokeLater(new Runnable()
-          {
-            public void run()
-            {
-              javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                  "Out of memory copying region!!"
-                  +
-                  "\nSee help files for increasing Java Virtual Machine memory."
-                  , "Out of memory",
-                  javax.swing.JOptionPane.WARNING_MESSAGE);
-            }
-          });
-
+      new OOMWarning("copying region", er);
       return;
     }
 
@@ -1502,20 +1489,7 @@ public class AlignFrame
       }
       catch (OutOfMemoryError er)
       {
-        er.printStackTrace();
-        javax.swing.SwingUtilities.invokeLater(new Runnable()
-        {
-          public void run()
-          {
-            javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                "Out of memory pasting sequences!!"
-                +
-                "\nSee help files for increasing Java Virtual Machine memory."
-                , "Out of memory",
-                javax.swing.JOptionPane.WARNING_MESSAGE);
-          }
-        });
-
+        new OOMWarning("Out of memory pasting sequences!!", er);
         return;
       }
 
@@ -3691,6 +3665,9 @@ protected void showProductsFor(SequenceI[] sel, Alignment ds, boolean isRegSel,
       {
         jalview.bin.Cache.log.error("Exception when finding crossreferences",e);
       }
+      catch (OutOfMemoryError e) {
+        new OOMWarning("whilst fetching crossreferences", e);
+      }
       catch (Error e)
       {
         jalview.bin.Cache.log.error("Error when finding crossreferences",e);
index 96dfc1c..64bf12a 100755 (executable)
@@ -426,26 +426,11 @@ public class AlignViewport
         }
         catch (OutOfMemoryError error)
         {
-          javax.swing.SwingUtilities.invokeLater(new Runnable()
-          {
-
-
-            public void run()
-            {
-              javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                  "Out of memory calculating conservation!!"
-                  +
-                  "\nSee help files for increasing Java Virtual Machine memory."
-                  , "Out of memory",
-                  javax.swing.JOptionPane.WARNING_MESSAGE);
-            }
-          });
+          new OOMWarning("calculating conservation",error);
 
           conservation = null;
           quality = null;
 
-          System.out.println("Conservation calculation: " + error);
-          System.gc();
 
         }
 
@@ -593,21 +578,7 @@ public class AlignViewport
 
           consensus = null;
           hconsensus = null;
-          javax.swing.SwingUtilities.invokeLater(new Runnable()
-          {
-            public void run()
-            {
-              javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                  "Out of memory calculating consensus!!"
-                  +
-                  "\nSee help files for increasing Java Virtual Machine memory."
-                  , "Out of memory",
-                  javax.swing.JOptionPane.WARNING_MESSAGE);
-            }
-          });
-
-          System.out.println("Consensus calculation: " + error);
-          System.gc();
+          new OOMWarning("calculating consensus",error);
         }
         UPDATING_CONSENSUS = false;
         updatingConsensus = false;
index d81de9b..3dc967e 100755 (executable)
@@ -986,19 +986,12 @@ public class AlignmentPanel
     }
     catch (OutOfMemoryError err)
     {
+      // Be noisy here.
       System.out.println("########################\n"
                          + "OUT OF MEMORY " + file + "\n"
                          + "########################");
-
-      JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                                            "Out of Memory Creating Image!!"
-                                            +
-                                            "\nSee help files for increasing Java Virtual Machine memory."
-                                            , "Out of memory",
-                                            JOptionPane.WARNING_MESSAGE);
-      System.out.println("Create IMAGE: " + err);
-      System.gc();
-
+      new OOMWarning("Creating Image for "+file,err);
+      // System.out.println("Create IMAGE: " + err);
     }
     catch (Exception ex)
     {
index 6454c59..7f4166b 100644 (file)
@@ -304,6 +304,10 @@ public synchronized void addSequence(SequenceI [] seq)
                        .getAbsolutePath());
       initJmol("load "+pdbentry.getFile());
     }
+    catch (OutOfMemoryError oomerror)
+    {
+      new OOMWarning("Retrieving PDB id "+pdbentry.getId()+" from MSD", oomerror);
+    }
     catch (Exception ex)
     {
       ex.printStackTrace();
index 00d3105..8e673f1 100755 (executable)
@@ -167,14 +167,7 @@ public class PCAPanel
     }
     catch (OutOfMemoryError er)
     {
-      JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                                            "Out of memory calculating PCA!!"
-                                            +
-                                            "\nSee help files for increasing Java Virtual Machine memory."
-                                            , "Out of memory",
-                                            JOptionPane.WARNING_MESSAGE);
-      System.out.println("PCAPanel: " + er);
-      System.gc();
+      new OOMWarning("calculating PCA", er);
 
     }
 
index 67f1ce0..9c8e129 100755 (executable)
@@ -335,21 +335,9 @@ public class SeqCanvas
       catch (OutOfMemoryError er)
       {
         System.gc();
-        System.out.println(er + " making image, SeqCanvas");
-        javax.swing.SwingUtilities.invokeLater(new Runnable()
-        {
-          public void run()
-          {
-            javax.swing.JOptionPane.showInternalMessageDialog(Desktop.
-                desktop,
-                "Out of memory creating alignment image!!"
-                +
-                "\nSee help files for increasing Java Virtual Machine memory."
-                , "Out of memory",
-                javax.swing.JOptionPane.WARNING_MESSAGE);
-          }
-        });
-
+        System.err.println("SeqCanvas OutOfMemory Redraw Error.\n"+er);
+        new OOMWarning("Creating alignment image for display",er);
+        
         return;
       }
     }
index 37bfc00..8c63f9c 100755 (executable)
@@ -395,6 +395,7 @@ public class SequenceFetcher extends JPanel implements Runnable
       e.printStackTrace();
     } catch (OutOfMemoryError e)
     {
+      // resets dialog box - so we don't use OOMwarning here.
       showErrorMessage("Out of Memory when retrieving "
               + textArea.getText()
               + " from "
@@ -407,11 +408,12 @@ public class SequenceFetcher extends JPanel implements Runnable
               + " from " + database.getSelectedItem());
       e.printStackTrace();
     }
-    guiWindow.setProgressBar(null, Thread.currentThread().hashCode());
     if (aresult != null)
     {
       parseResult(aresult, null, null);
     }
+    // only remove visual delay after we finished parsing.
+    guiWindow.setProgressBar(null, Thread.currentThread().hashCode());
     resetDialog();
   }
 
index a67599b..662bf31 100644 (file)
@@ -238,6 +238,10 @@ public class DBRefFetcher implements Runnable
           {\r
             ex.printStackTrace();\r
           }\r
+          catch (OutOfMemoryError err)\r
+          {\r
+            new OOMWarning("retrieving database references ("+queryString.toString()+")", err);\r
+          }\r
           if (retrieved != null)\r
           {\r
             transferReferences(sdataset, dbSources[db], retrieved);\r
index 3ad9690..106f693 100644 (file)
@@ -293,15 +293,9 @@ public abstract class WSThread
             jobs[j].result = null; // may contain out of date result object\r
             wsInfo.setStatus(jobs[j].jobnum,\r
                              WebserviceInfo.STATE_STOPPED_ERROR);\r
-            JOptionPane\r
-                .showInternalMessageDialog(\r
-                    Desktop.desktop,\r
-                    "Out of memory handling result for job !!"\r
-                    +\r
-                    "\nSee help files for increasing Java Virtual Machine memory.",\r
-                    "Out of memory", JOptionPane.WARNING_MESSAGE);\r
             Cache.log.error("Out of memory when retrieving Job " + j + " id:" +\r
                             WsUrl + "/" + jobs[j].jobId, er);\r
+            new jalview.gui.OOMWarning("retrieving result for "+WebServiceName,er);\r
             System.gc();\r
           }\r
         }\r