Don't rewrite -Xmx if we couldn't determine the current value (IDEA-219388)

GitOrigin-RevId: c5c0a899a9d6f54bcb0a35b9bca7a62a3762f76c
This commit is contained in:
Dmitry Jemerov
2019-07-31 19:04:01 +03:00
committed by intellij-monorepo-bot
parent 7293bf9e09
commit 9737ecafac
@@ -17,7 +17,12 @@ class MemorySizeConfigurator : StartupActivity {
override fun runActivity(project: Project) {
if (ApplicationManager.getApplication().isUnitTestMode) return
val currentXmx = VMOptions.readOption(VMOptions.MemoryKind.HEAP, true)
var currentXmx = VMOptions.readOption(VMOptions.MemoryKind.HEAP, true)
if (currentXmx < 0) currentXmx = VMOptions.readOption(VMOptions.MemoryKind.HEAP, false)
if (currentXmx < 0) {
// Don't know how much -Xmx we have
return
}
if (currentXmx > 750) {
// Memory has already been adjusted by the user manually
return
@@ -31,12 +36,14 @@ class MemorySizeConfigurator : StartupActivity {
val newXmx = MemorySizeConfiguratorService.getInstance().getSuggestedMemorySize(currentXmx, totalPhysicalMemory.toInt())
val currentXms = VMOptions.readOption(VMOptions.MemoryKind.MIN_HEAP, true)
if (newXmx < currentXms) return
var currentXms = VMOptions.readOption(VMOptions.MemoryKind.MIN_HEAP, true)
if (currentXms < 0) currentXms = VMOptions.readOption(VMOptions.MemoryKind.MIN_HEAP, false)
if (currentXms < 0 || newXmx < currentXms) return
VMOptions.writeOption(VMOptions.MemoryKind.HEAP, newXmx)
PropertiesComponent.getInstance().setValue("ide.memory.adjusted", true)
LOG.info("Physical memory ${totalPhysicalMemory}M, -Xmx adjusted to ${newXmx}M")
LOG.info("Physical memory ${totalPhysicalMemory}M, minimum memory size ${currentXms}M, -Xmx adjusted from ${currentXmx}M to ${newXmx}M")
}
companion object {