-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Launcher classes for WhiteRabbit and RiaH
The Launcher class will replace the need for scripts to launch the JAR files with enough memory allocated Found this trick at: http://silentdevelopment.blogspot.com/2010/03/how-to-set-or-increase-xmx-heap-memory.html
- Loading branch information
1 parent
9f629fd
commit 41d463e
Showing
3 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.ohdsi.utilities; | ||
|
||
import org.ohdsi.rabbitInAHat.RabbitInAHatMain; | ||
|
||
/* Adapted from code found on: | ||
* http://silentdevelopment.blogspot.com/2010/03/how-to-set-or-increase-xmx-heap-memory.html | ||
*/ | ||
public class RabbitInAHatLauncher { | ||
private final static int MIN_HEAP = 1500; | ||
|
||
public static void main(String[] args) throws Exception { | ||
|
||
float heapSizeMegs = (Runtime.getRuntime().maxMemory() / 1024) / 1024; | ||
|
||
if (heapSizeMegs > MIN_HEAP) { | ||
System.out.println("Launching with current VM"); | ||
RabbitInAHatMain.main(args); | ||
} else { | ||
System.out.println("Starting new VM"); | ||
String pathToJar = RabbitInAHatMain.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath(); | ||
ProcessBuilder pb = new ProcessBuilder("java", "-Xmx" + MIN_HEAP + "m", "-classpath", pathToJar, "org.ohdsi.rabbitInAHat.RabbitInAHatMain"); | ||
pb.start(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.ohdsi.utilities; | ||
|
||
import org.ohdsi.whiteRabbit.WhiteRabbitMain; | ||
|
||
/* Adapted from code found on: | ||
* http://silentdevelopment.blogspot.com/2010/03/how-to-set-or-increase-xmx-heap-memory.html | ||
*/ | ||
public class WhiteRabbitLauncher { | ||
private final static int MIN_HEAP = 1500; | ||
|
||
public static void main(String[] args) throws Exception { | ||
|
||
float heapSizeMegs = (Runtime.getRuntime().maxMemory() / 1024) / 1024; | ||
|
||
if (heapSizeMegs > MIN_HEAP) { | ||
System.out.println("Launching with current VM"); | ||
WhiteRabbitMain.main(args); | ||
} else { | ||
System.out.println("Starting new VM"); | ||
String pathToJar = WhiteRabbitMain.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath(); | ||
ProcessBuilder pb = new ProcessBuilder("java", "-Xmx" + MIN_HEAP + "m", "-classpath", pathToJar, "org.ohdsi.whiteRabbit.WhiteRabbitMain"); | ||
pb.start(); | ||
} | ||
} | ||
} |