Skip to content

Commit

Permalink
'#1712: set -Xmx to 1/4 RAM when processing if not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
lfcnassif committed Jun 27, 2023
1 parent 9c28d8d commit beb3d48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions iped-app/src/main/java/iped/app/bootstrap/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ protected String getMainClassName() {
return Main.class.getCanonicalName();
}

protected float getRAMToHeapFactor() {
return 0.25f;
}

protected void run(String args[]) {

List<String> heapArgs = new ArrayList<>();
Expand Down Expand Up @@ -110,8 +114,8 @@ protected void run(String args[]) {
}

if (!XmxDefined) {
// if -Xmx is not specified, set to half the physical memory, up to 32GB
long memSize = Math.min(physicalMemory / 2, 32 * 1024 * 1024 * 1024);
// if -Xmx is not specified, set it, up to 32GB
long memSize = Math.min((long) (physicalMemory * getRAMToHeapFactor()), 32 * 1024 * 1024 * 1024);
heapArgs.add("-Xmx" + (memSize / (1024 * 1024)) + "M");
}

Expand Down
5 changes: 5 additions & 0 deletions iped-app/src/main/java/iped/app/bootstrap/BootstrapUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ protected String getMainClassName() {
return AppMain.class.getCanonicalName();
}

@Override
protected float getRAMToHeapFactor() {
return 0.5f;
}

}

0 comments on commit beb3d48

Please sign in to comment.