[m-rev.] diff: increase java memory limit for standard library

Peter Wang novalazy at gmail.com
Thu Nov 5 12:59:53 AEDT 2009


Branches: main

library/Mmakefile:
	It appears that javac -Xmx256m still runs out of memory when building
	the standard library in the java grade on 32-bit machines. Bump up the
	maximum size to 512 MB for the standard library, but not in general.

README.Java:
	Describe how to increase the memory limit with mmc --make. 

diff --git a/README.Java b/README.Java
index 3d0baf0..29d0664 100644
--- a/README.Java
+++ b/README.Java
@@ -161,6 +161,7 @@ A. The following implementation features are not supported:
 
    This list is probably not complete.
 
+
 Q. So how do I enable Java-level debugging?
 
 A. By default, javac already generates line number and source file debugging
@@ -173,4 +174,16 @@ A. By default, javac already generates line number and source file debugging
    as part of the Java SDK distribution, to debug your program.
    For more information, see the documentation for javac and jdb.
 
+
+Q. The Java compiler runs out of memory!
+
+A. You are probably hitting an artificial limit. You can pass an option to
+   the javac program to increase the limit, e.g.
+
+        mmc --make foo --java --java-flag -J-Xmx512m
+
+   Or in a Mercury.options file:
+
+        JAVACFLAGS += -J-Xmx512m
+
 -----------------------------------------------------------------------------
diff --git a/library/Mmakefile b/library/Mmakefile
index 5353f22..f6a6af3 100644
--- a/library/Mmakefile
+++ b/library/Mmakefile
@@ -119,6 +119,14 @@ endif
 # Let javac find jmercury/runtime/*.java files.
 JAVACFLAGS   += -sourcepath .
 
+# -Xmx256m doesn't always seem to be enough memory to build the standard
+# library. This bumps up the memory when building the standard library
+# if the javac executable accepts the -J-Xmx flag, without bumping up
+# the memory requirements in general.
+ifneq ("$(findstring -J-Xmx,$(JAVACFLAGS))","")
+JAVACFLAGS   += -J-Xmx512m
+endif
+
 MTAGS	= $(SCRIPTS_DIR)/mtags
 
 LN	= ln

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list