From b3b1eecf938fdc9d0bd8f954bc05ec38763299fb Mon Sep 17 00:00:00 2001 From: acolyer Date: Thu, 15 Jan 2004 11:43:14 +0000 Subject: [PATCH] Fix for Bugzilla Bug 36234 out of memory error when compiling --- .../src/org/aspectj/tools/ajc/Main.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java b/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java index 287508440..2be51cb6d 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java @@ -67,6 +67,14 @@ public class Main { + "at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ" + LangUtil.EOL + "To make the bug a priority, please include a test program" + LangUtil.EOL + "that can reproduce this exception." + LangUtil.EOL; + + private static final String OUT_OF_MEMORY_MSG + = "AspectJ " + Version.text + " ran out of memory during compilation:" + LangUtil.EOL + LangUtil.EOL + + "Please increase the memory available to ajc by editing the ajc script " + LangUtil.EOL + + "found in your AspectJ installation directory. The -Xmx parameter value" + LangUtil.EOL + + "should be increased from 64M (default) to 128M or even 256M." + LangUtil.EOL + LangUtil.EOL + + "See the AspectJ FAQ available from the documentation link" + LangUtil.EOL + + "on the AspectJ home page at http://www.eclipse.org/aspectj"; /** @param args the String[] of command-line arguments */ public static void main(String[] args) throws IOException { @@ -153,7 +161,16 @@ public class Main { ourHandler.setInterceptor(MessagePrinter.TERSE); } } - run(args, holder); + + // make sure we handle out of memory gracefully... + try { + // byte[] b = new byte[100000000]; for testing OoME only! + run(args, holder); + } catch (OutOfMemoryError outOfMemory) { + IMessage outOfMemoryMessage = new Message(OUT_OF_MEMORY_MSG,null,true); + holder.handleMessage(outOfMemoryMessage); + systemExit(holder); // we can't reasonably continue from this point. + } boolean skipExit = false; if (useSystemExit && !LangUtil.isEmpty(args)) { // sigh - pluck -noExit -- 2.39.5