From a581135c768ce6c60c38bbd47003477f8c557eea Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 29 Aug 2008 11:04:33 +0000 Subject: [PATCH] use OOMwarning to warn user when out of Memory occurs --- src/jalview/gui/AlignFrame.java | 33 +++++---------------------------- src/jalview/gui/AlignViewport.java | 33 ++------------------------------- src/jalview/gui/AlignmentPanel.java | 13 +++---------- src/jalview/gui/AppJmol.java | 4 ++++ src/jalview/gui/PCAPanel.java | 9 +-------- src/jalview/gui/SeqCanvas.java | 18 +++--------------- src/jalview/gui/SequenceFetcher.java | 4 +++- src/jalview/ws/DBRefFetcher.java | 4 ++++ src/jalview/ws/WSThread.java | 8 +------- 9 files changed, 26 insertions(+), 100 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 1320aa0..3aa69f1 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -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); diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 96dfc1c..64bf12a 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -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; diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index d81de9b..3dc967e 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -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) { diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index 6454c59..7f4166b 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -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(); diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index 00d3105..8e673f1 100755 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -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); } diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 67f1ce0..9c8e129 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -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; } } diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 37bfc00..8c63f9c 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -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(); } diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index a67599b..662bf31 100644 --- a/src/jalview/ws/DBRefFetcher.java +++ b/src/jalview/ws/DBRefFetcher.java @@ -238,6 +238,10 @@ public class DBRefFetcher implements Runnable { ex.printStackTrace(); } + catch (OutOfMemoryError err) + { + new OOMWarning("retrieving database references ("+queryString.toString()+")", err); + } if (retrieved != null) { transferReferences(sdataset, dbSources[db], retrieved); diff --git a/src/jalview/ws/WSThread.java b/src/jalview/ws/WSThread.java index 3ad9690..106f693 100644 --- a/src/jalview/ws/WSThread.java +++ b/src/jalview/ws/WSThread.java @@ -293,15 +293,9 @@ public abstract class WSThread jobs[j].result = null; // may contain out of date result object wsInfo.setStatus(jobs[j].jobnum, WebserviceInfo.STATE_STOPPED_ERROR); - JOptionPane - .showInternalMessageDialog( - Desktop.desktop, - "Out of memory handling result for job !!" - + - "\nSee help files for increasing Java Virtual Machine memory.", - "Out of memory", JOptionPane.WARNING_MESSAGE); Cache.log.error("Out of memory when retrieving Job " + j + " id:" + WsUrl + "/" + jobs[j].jobId, er); + new jalview.gui.OOMWarning("retrieving result for "+WebServiceName,er); System.gc(); } } -- 1.7.10.2