summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-12-14 10:32:52 +1100
committermd_5 <git@md-5.net>2018-12-14 10:32:52 +1100
commit93d6e6d422dbabadc56fa48c58441974f07a8ce9 (patch)
treeba7749f11315a9a14e803ed0ebbc723e090d25ee
parentf254dfa94052d748adf6ea693a4b504906b516b2 (diff)
downloadbuildtools-93d6e6d422dbabadc56fa48c58441974f07a8ce9.tar
buildtools-93d6e6d422dbabadc56fa48c58441974f07a8ce9.tar.gz
buildtools-93d6e6d422dbabadc56fa48c58441974f07a8ce9.tar.lz
buildtools-93d6e6d422dbabadc56fa48c58441974f07a8ce9.tar.xz
buildtools-93d6e6d422dbabadc56fa48c58441974f07a8ce9.zip
BUILDTOOLS-431: Detect and warn about low memory. Seems to occur on 32 bit Java installs.
-rw-r--r--src/main/java/org/spigotmc/builder/Bootstrap.java13
-rw-r--r--src/main/java/org/spigotmc/builder/Builder.java13
2 files changed, 24 insertions, 2 deletions
diff --git a/src/main/java/org/spigotmc/builder/Bootstrap.java b/src/main/java/org/spigotmc/builder/Bootstrap.java
index 57a2b78..2a1ceba 100644
--- a/src/main/java/org/spigotmc/builder/Bootstrap.java
+++ b/src/main/java/org/spigotmc/builder/Bootstrap.java
@@ -1,5 +1,7 @@
package org.spigotmc.builder;
+import com.google.common.base.Joiner;
+
public class Bootstrap
{
@@ -11,7 +13,7 @@ public class Bootstrap
{
System.err.println( "Outdated Java detected (" + javaVersion + "). BuildTools requires at least Java 7. Please update Java and try again." );
System.err.println( "You may use java -version to double check your Java version." );
- return;
+ System.exit( 1 );
}
if ( javaVersion.getVersion() < JavaVersion.JAVA_8.getVersion() )
@@ -26,6 +28,15 @@ public class Bootstrap
System.err.println( "*** WARNING *** You may use java -version to double check your Java version." );
}
+ long memoryMb = Runtime.getRuntime().maxMemory() >> 20;
+ if ( memoryMb < 512 )
+ {
+ System.err.println( "BuildTools requires at least 512M of memory to run (1024M recommended), but has only detected " + memoryMb + "M." );
+ System.err.println( "This can often occur if you are running a 32-bit system, or one with low RAM." );
+ System.err.println( "Please re-run BuildTools with manually specified memory, e.g: java -Xmx1024M -jar BuildTools.jar " + Joiner.on( ' ' ).join( args ) );
+ System.exit( 1 );
+ }
+
Builder.main( args );
}
}
diff --git a/src/main/java/org/spigotmc/builder/Builder.java b/src/main/java/org/spigotmc/builder/Builder.java
index 8a5953e..82bb069 100644
--- a/src/main/java/org/spigotmc/builder/Builder.java
+++ b/src/main/java/org/spigotmc/builder/Builder.java
@@ -30,6 +30,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
+import java.lang.management.ManagementFactory;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
@@ -669,7 +670,17 @@ public class Builder
}
if ( !pb.environment().containsKey( "_JAVA_OPTIONS" ) )
{
- pb.environment().put( "_JAVA_OPTIONS", "-Djdk.net.URLClassPath.disableClassPathURLCheck=true" );
+ String javaOptions = "-Djdk.net.URLClassPath.disableClassPathURLCheck=true";
+
+ for ( String arg : ManagementFactory.getRuntimeMXBean().getInputArguments() )
+ {
+ if ( arg.startsWith( "-Xmx" ) )
+ {
+ javaOptions += " " + arg;
+ }
+ }
+
+ pb.environment().put( "_JAVA_OPTIONS", javaOptions );
}
if ( msysDir != null )
{