mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
infer forked groovyc's Xmx from build process Xmx (IDEA-195598)
This commit is contained in:
@@ -101,4 +101,16 @@ public class Utils {
|
||||
public static String formatDuration(long duration) {
|
||||
return StringUtil.formatDuration(duration);
|
||||
}
|
||||
|
||||
public static int suggestForkedCompilerHeapSize() {
|
||||
//final JpsProject project = context.getProjectDescriptor().getProject();
|
||||
//final JpsJavaCompilerConfiguration config = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
|
||||
//final JpsJavaCompilerOptions options = config.getCurrentCompilerOptions();
|
||||
//return options.MAXIMUM_HEAP_SIZE;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
final ExternalJavacManager server = ensureJavacServerStarted(context);
|
||||
rc = server.forkJavac(
|
||||
forkSdk.getFirst(),
|
||||
getExternalJavacHeapSize(),
|
||||
Utils.suggestForkedCompilerHeapSize(),
|
||||
vmOptions, options, platformCp, classPath, modulePath, sourcePath,
|
||||
files, outs, diagnosticSink, classesConsumer, compilingTool, context.getCancelStatus()
|
||||
);
|
||||
@@ -484,18 +484,6 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static int getExternalJavacHeapSize() {
|
||||
//final JpsProject project = context.getProjectDescriptor().getProject();
|
||||
//final JpsJavaCompilerConfiguration config = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
|
||||
//final JpsJavaCompilerOptions options = config.getCurrentCompilerOptions();
|
||||
//return options.MAXIMUM_HEAP_SIZE;
|
||||
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
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String validateCycle(CompileContext context, ModuleChunk chunk) {
|
||||
final JpsJavaExtensionService javaExt = JpsJavaExtensionService.getInstance();
|
||||
|
||||
+2
-1
@@ -31,6 +31,7 @@ import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.cmdline.ClasspathBootstrap;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.ExternalProcessUtil;
|
||||
import org.jetbrains.jps.incremental.Utils;
|
||||
import org.jetbrains.jps.model.java.JpsJavaSdkType;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdk;
|
||||
import org.jetbrains.jps.service.SharedThreadPool;
|
||||
@@ -74,7 +75,7 @@ class ForkedGroovyc implements GroovycFlavor {
|
||||
JpsGroovySettings settings = JpsGroovycRunner.getGroovyCompilerSettings(context);
|
||||
|
||||
List<String> vmParams = ContainerUtilRt.newArrayList();
|
||||
vmParams.add("-Xmx" + System.getProperty("groovyc.heap.size", settings.heapSize) + "m");
|
||||
vmParams.add("-Xmx" + System.getProperty("groovyc.heap.size", String.valueOf(Utils.suggestForkedCompilerHeapSize())) + "m");
|
||||
vmParams.add("-Dfile.encoding=" + System.getProperty("file.encoding"));
|
||||
//vmParams.add("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5239");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user