Skip to content

Commit

Permalink
Showing 52 changed files with 777 additions and 462 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ sudo: false

before_script:
- export MAVEN_SKIP_RC=true
- export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=512m"
- export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"
- unset GEM_PATH GEM_HOME IRBRC JRUBY_OPTS
- "export PATH=`pwd`/bin:$PATH"
- echo $HOME
@@ -22,6 +22,7 @@ os:

env:
global:
- JAVA_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xmx512M"
- MALLOC_ARENA_MAX=2
matrix:
- JT='test specs :language'
@@ -45,6 +46,7 @@ matrix:
jdk: oraclejdk8
- env: PHASE='-Pj2ee'
jdk: oraclejdk7
- env: JT='test integration'
# NOTE: build seems to never start (waited for any to finish for more than a day) - probably a travis-ci bug
#- env: PHASE='-Pmain'
# sudo: required
4 changes: 0 additions & 4 deletions bin/jruby.bash
Original file line number Diff line number Diff line change
@@ -91,10 +91,6 @@ if [ -z "$JAVACMD" ] ; then
fi
fi

if [ -z "$JAVA_MEM" ] ; then
JAVA_MEM=-Xmx500m
fi

if [ -z "$JAVA_STACK" ] ; then
JAVA_STACK=-Xss2048k
fi
30 changes: 18 additions & 12 deletions core/src/main/java/org/jruby/Main.java
Original file line number Diff line number Diff line change
@@ -358,21 +358,32 @@ private Status handleOutOfMemory(OutOfMemoryError oome) {
System.gc(); // try to clean up a bit of space, hopefully, so we can report this error

String oomeMessage = oome.getMessage();
boolean heapError = false;

if (oomeMessage != null) {
if (oomeMessage.contains("PermGen")) {
// report permgen memory error
config.getError().println("Error: Your application exhausted PermGen area of the heap.");
config.getError().println("Specify -J-XX:MaxPermSize=###M to increase it (### = PermGen size in MB).");
} else if (oomeMessage.contains("unable to create new native thread")) {
// report thread exhaustion error
config.getError().println("Error: Your application demanded too many live threads, perhaps for Fiber or Enumerator.");
config.getError().println("Ensure your old Fibers and Enumerators are being cleaned up.");
} else {
heapError = true;
}
}

if (oomeMessage != null && oomeMessage.contains("PermGen")) { // report permgen memory error
config.getError().println("Error: Your application exhausted PermGen area of the heap.");
config.getError().println("Specify -J-XX:MaxPermSize=###M to increase it (### = PermGen size in MB).");

} else { // report heap memory error
if (heapError) { // report heap memory error

String memoryMax = getRuntimeFlagValue("-Xmx");

if (memoryMax != null) {
config.getError().println("Error: Your application used more memory than the safety cap of " + memoryMax + ".");
} else {
config.getError().println("Error: Your application used more memory than the default safety cap.");
config.getError().println("Error: Your application used more memory than the automatic cap of " + Runtime.getRuntime().maxMemory() / 1024 / 1024 + "MB.");
}
config.getError().println("Specify -J-Xmx####m to increase it (#### = cap size in MB).");
config.getError().println("Specify -J-Xmx####M to increase it (#### = cap size in MB).");
}

if (config.isVerbose()) {
@@ -408,7 +419,6 @@ private Status handleMainExit(MainExitException mee) {
}

private Status doRunFromMain(Ruby runtime, InputStream in, String filename) {
long now = -1;
try {
doCheckSecurityManager();

@@ -474,10 +484,6 @@ private void doSetContextClassLoader(Ruby runtime) {
}
}

private void doProcessArguments(InputStream in) {
config.processArguments(config.parseShebangOptions(in));
}

private void doPrintProperties() {
if (config.getShouldPrintProperties()) {
config.getOutput().print(OutputStrings.getPropertyHelp());
25 changes: 16 additions & 9 deletions core/src/main/java/org/jruby/RubyDir.java
Original file line number Diff line number Diff line change
@@ -812,24 +812,31 @@ public static IRubyObject getHomeDirectoryPath(ThreadContext context, String use
throw runtime.newArgumentError("user " + user + " doesn't exist");
}

static final ByteList HOME = new ByteList(new byte[] {'H','O','M','E'}, false);

public static RubyString getHomeDirectoryPath(ThreadContext context) {
Ruby runtime = context.runtime;
IRubyObject systemHash = runtime.getObject().getConstant("ENV_JAVA");
RubyHash envHash = (RubyHash) runtime.getObject().getConstant("ENV");
IRubyObject home = envHash.op_aref(context, runtime.newString("HOME"));
final RubyString homeKey = RubyString.newStringShared(context.runtime, HOME);
return getHomeDirectoryPath(context, context.runtime.getENV().op_aref(context, homeKey));
}

if (home == null || home.isNil()) {
home = systemHash.callMethod(context, "[]", runtime.newString("user.home"));
static RubyString getHomeDirectoryPath(ThreadContext context, IRubyObject home) {
final Ruby runtime = context.runtime;

if (home == null || home == context.nil) {
IRubyObject ENV_JAVA = runtime.getObject().getConstant("ENV_JAVA");
home = ENV_JAVA.callMethod(context, "[]", runtime.newString("user.home"));
}

if (home == null || home.isNil()) {
home = envHash.op_aref(context, runtime.newString("LOGDIR"));
if (home == null || home == context.nil) {
RubyHash ENV = (RubyHash) runtime.getObject().getConstant("ENV");
home = ENV.op_aref(context, runtime.newString("LOGDIR"));
}

if (home == null || home.isNil()) {
if (home == null || home == context.nil) {
throw runtime.newArgumentError("user.home/LOGDIR not set");
}

return (RubyString) home;
}

}
13 changes: 12 additions & 1 deletion core/src/main/java/org/jruby/RubyEnumerator.java
Original file line number Diff line number Diff line change
@@ -700,7 +700,18 @@ public synchronized IRubyObject peek() {
}

private void ensureStarted() {
if (thread == null) future = runtime.getFiberExecutor().submit(this);
try {
if (thread == null) future = runtime.getFiberExecutor().submit(this);
} catch (OutOfMemoryError oome) {
String oomeMessage = oome.getMessage();
if (oomeMessage != null && oomeMessage.contains("unable to create new native thread")) {
// try to clean out stale enumerator threads by forcing GC
System.gc();
future = runtime.getFiberExecutor().submit(this);
} else {
throw oome;
}
}
}

private IRubyObject peekTake() {
Loading

0 comments on commit fa14521

Please sign in to comment.