From: jprocter Date: Tue, 25 Sep 2012 10:20:17 +0000 (+0100) Subject: JAL-1173 - trap redraw buffer OOM errors. needs a test case - since the dialog doesn... X-Git-Tag: Jalview_2_9~294 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d64f1df4fdb6c90c7ed36624174eac8b1dd52511;p=jalview.git JAL-1173 - trap redraw buffer OOM errors. needs a test case - since the dialog doesn't get raised reliably. --- diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 411c244..23d8341 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -754,8 +754,17 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (image == null || imgWidth != image.getWidth() || image.getHeight(this) != getHeight()) { + try { image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(), BufferedImage.TYPE_INT_RGB); + } catch (OutOfMemoryError oom) + { + try { + System.gc(); + } catch (Exception x){}; + new OOMWarning("Couldn't allocate memory to redraw screen. Please restart Jalview", oom); + return; + } gg = (Graphics2D) image.getGraphics(); if (av.antiAlias)