--- /dev/null
+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)\r
+ * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ * \r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
+package jalview.gui;\r
+\r
+import java.awt.Component;\r
+\r
+public class OOMWarning implements Runnable\r
+{\r
+ String action=null;\r
+ String instructions = "";\r
+ Component desktop=null;\r
+ /**\r
+ * Raise an out of memory error.\r
+ * @param action - what was going on when OutOfMemory exception occured.\r
+ * @param instance - Window where the dialog will appear\r
+ * @param oomex - the actual exception - to be written to stderr or debugger.\r
+ */\r
+ OOMWarning(String action, OutOfMemoryError oomex, Component instance) {\r
+ this.action = action;\r
+ desktop = instance;\r
+ if (oomex!=null)\r
+ {\r
+ if (jalview.bin.Cache.log!=null)\r
+ {\r
+ jalview.bin.Cache.log.error("Out of Memory when "+action, oomex);\r
+ } else {\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
+ public OOMWarning(String string, OutOfMemoryError oomerror)\r
+ {\r
+ this(string, oomerror, Desktop.desktop);\r
+ }\r
+ public void run()\r
+ {\r
+ javax.swing.JOptionPane.showInternalMessageDialog(desktop,\r
+ "Out of memory when " + action + "!!"\r
+ +\r
+ "\nSee help files for increasing Java Virtual Machine memory."\r
+ , "Out of memory",\r
+ javax.swing.JOptionPane.WARNING_MESSAGE);\r
+ }\r
+\r
+}\r