mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix int overwlow in max heap size calculations for external javac process (follow-up for IDEA-164402)
This commit is contained in:
@@ -504,7 +504,10 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
//final JpsJavaCompilerConfiguration config = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
|
||||
//final JpsJavaCompilerOptions options = config.getCurrentCompilerOptions();
|
||||
//return options.MAXIMUM_HEAP_SIZE;
|
||||
final int maxMbytes = (int)Runtime.getRuntime().maxMemory() / 1048576;
|
||||
final int maxMbytes = (int)(Runtime.getRuntime().maxMemory() / 1048576L);
|
||||
if (maxMbytes < 0) {
|
||||
return -1; // in case of int overflow, return -1 to let VM choose the heap size
|
||||
}
|
||||
return Math.max(maxMbytes * 75 / 100, 256); // minimum 256 Mb, maximum 75% from JPS max heap size
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user