Skip to content

Commit

Permalink
[jvm] Add some cleanup when intercepting exits.
Browse files Browse the repository at this point in the history
The EvalServer adds a few minor headaches with memory usage, which we have to
take care off manually.  There's probably other ways still out there to reduce
memory usage, but this set at least finishes the Perl 6 spectest without hangs
or notable OutOfMemory exceptions.
  • Loading branch information
peschwa committed Jan 25, 2018
1 parent dd8b1ad commit b88de49
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/vm/jvm/runtime/org/perl6/nqp/runtime/GlobalContext.java
Expand Up @@ -307,6 +307,14 @@ public void exit(int status) {

if (exitStatus < 0) exitStatus = status;
shuttingDown = true;

for (Thread th : allThreads.keySet()) {
if (java.lang.Thread.currentThread() == th)
continue;
th.interrupt();
}
mainThread = null;
currentThreadCtxRef = null;
throw new ThreadDeath();
}

Expand Down
3 changes: 2 additions & 1 deletion src/vm/jvm/runtime/org/perl6/nqp/runtime/LibraryLoader.java
Expand Up @@ -125,7 +125,8 @@ public static Class<?> loadFile(String cf, boolean shared) throws Exception {
}

public static Class<?> loadNew(byte[] bytes, byte[] serial) {
return new IgnoreNameClassLoader(bytes, serial).loadClass();
IgnoreNameClassLoader incl = new IgnoreNameClassLoader(bytes, serial);
return incl.loadClass();
}

private static class IgnoreNameClassLoader extends ClassLoader {
Expand Down
1 change: 1 addition & 0 deletions src/vm/jvm/runtime/org/perl6/nqp/tools/EvalServer.java
Expand Up @@ -197,6 +197,7 @@ private void eval() throws Exception {
if (entryRef == null)
throw new RuntimeException("This class is not an entry point");
Ops.invokeMain(gc.mainThread, entryRef, cuType.getName(), argv);
gc.exit(0);
}
}

Expand Down

0 comments on commit b88de49

Please sign in to comment.