From 9fbe0b7db00341a5b0707731ecb7c5ea3254b9b4 Mon Sep 17 00:00:00 2001 From: kiramt Date: Tue, 29 Aug 2017 10:48:54 +0100 Subject: [PATCH] JAL-2665 OOM check --- src/jalview/gui/SeqCanvas.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 8004cac..f34ab2c 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -453,8 +453,20 @@ public class SeqCanvas extends JComponent implements ViewportListenerI int canvasHeight, int startRes) { SequenceGroup group = av.getSelectionGroup(); - BufferedImage selectImage = new BufferedImage(canvasWidth, canvasHeight, - BufferedImage.TYPE_INT_ARGB); // ARGB so alpha compositing works + BufferedImage selectImage = null; + + try + { + selectImage = new BufferedImage(canvasWidth, canvasHeight, + BufferedImage.TYPE_INT_ARGB); // ARGB so alpha compositing works + } catch (OutOfMemoryError er) + { + System.gc(); + System.err.println("Print image OutOfMemory Error.\n" + er); + new OOMWarning("Creating wrapped alignment image for printing", er); + + return; + } if (group != null) { -- 1.7.10.2