mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[ui] perm. gen -> metaspace in OOME dialog (IDEA-165796)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -107,7 +107,7 @@ public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
|
||||
if (t instanceof OutOfMemoryError) {
|
||||
if (message != null && message.contains("unable to create new native thread")) return null;
|
||||
if (message != null && message.contains("PermGen")) return MemoryKind.PERM_GEN;
|
||||
if (message != null && message.contains("Metaspace")) return MemoryKind.METASPACE;
|
||||
return MemoryKind.HEAP;
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,13 +18,12 @@ package com.intellij.diagnostic;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class DropAnOutOfPermGenMemoryErrorAction extends DumbAwareAction {
|
||||
public DropAnOutOfPermGenMemoryErrorAction() {
|
||||
super ("Drop an perm gen OutOfMemoryError");
|
||||
public class DropAnOutOfMetaspaceErrorAction extends DumbAwareAction {
|
||||
public DropAnOutOfMetaspaceErrorAction() {
|
||||
super ("Drop an OutOfMemoryError in Metaspace");
|
||||
}
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
throw new OutOfMemoryError("foo PermGen foo");
|
||||
throw new OutOfMemoryError("foo Metaspace foo");
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@
|
||||
<text value="Label"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="11e32" class="com.intellij.ui.components.JBLabel" binding="myPermGenSizeLabel">
|
||||
<component id="11e32" class="com.intellij.ui.components.JBLabel" binding="myMetaspaceSizeLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="1" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
@@ -67,7 +67,7 @@
|
||||
<text value="Label"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="2cb23" class="javax.swing.JTextField" binding="myPermGenSizeField" default-binding="true">
|
||||
<component id="2cb23" class="javax.swing.JTextField" binding="myMetaspaceSizeField" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
@@ -75,7 +75,7 @@
|
||||
<columns value="6"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e1ed0" class="com.intellij.ui.components.JBLabel" binding="myPermGenUnitsLabel">
|
||||
<component id="e1ed0" class="com.intellij.ui.components.JBLabel" binding="myMetaspaceUnitsLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
@@ -83,7 +83,7 @@
|
||||
<text value="MB"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="59bf8" class="com.intellij.ui.components.JBLabel" binding="myPermGenCurrentValueLabel">
|
||||
<component id="59bf8" class="com.intellij.ui.components.JBLabel" binding="myMetaspaceCurrentValueLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class OutOfMemoryDialog extends DialogWrapper {
|
||||
private final MemoryKind myMemoryKind;
|
||||
@@ -44,10 +43,10 @@ public class OutOfMemoryDialog extends DialogWrapper {
|
||||
private JTextField myHeapSizeField;
|
||||
private JBLabel myHeapUnitsLabel;
|
||||
private JBLabel myHeapCurrentValueLabel;
|
||||
private JBLabel myPermGenSizeLabel;
|
||||
private JTextField myPermGenSizeField;
|
||||
private JBLabel myPermGenUnitsLabel;
|
||||
private JBLabel myPermGenCurrentValueLabel;
|
||||
private JBLabel myMetaspaceSizeLabel;
|
||||
private JTextField myMetaspaceSizeField;
|
||||
private JBLabel myMetaspaceUnitsLabel;
|
||||
private JBLabel myMetaspaceCurrentValueLabel;
|
||||
private JBLabel myCodeCacheSizeLabel;
|
||||
private JTextField myCodeCacheSizeField;
|
||||
private JBLabel myCodeCacheUnitsLabel;
|
||||
@@ -75,12 +74,10 @@ public class OutOfMemoryDialog extends DialogWrapper {
|
||||
else {
|
||||
mySettingsFileHintLabel.setVisible(false);
|
||||
myHeapSizeField.setEnabled(false);
|
||||
myPermGenSizeField.setEnabled(false);
|
||||
myMetaspaceSizeField.setEnabled(false);
|
||||
myCodeCacheSizeField.setEnabled(false);
|
||||
}
|
||||
|
||||
Arrays.asList(myPermGenSizeLabel, myPermGenSizeField, myPermGenUnitsLabel, myPermGenCurrentValueLabel).forEach(c -> c.setVisible(false));
|
||||
|
||||
myContinueAction = new DialogWrapperAction(DiagnosticBundle.message("diagnostic.out.of.memory.continue")) {
|
||||
@Override
|
||||
protected void doAction(ActionEvent e) {
|
||||
@@ -107,7 +104,7 @@ public class OutOfMemoryDialog extends DialogWrapper {
|
||||
};
|
||||
|
||||
configControls(MemoryKind.HEAP, myHeapSizeLabel, myHeapSizeField, myHeapUnitsLabel, myHeapCurrentValueLabel);
|
||||
configControls(MemoryKind.PERM_GEN, myPermGenSizeLabel, myPermGenSizeField, myPermGenUnitsLabel, myPermGenCurrentValueLabel);
|
||||
configControls(MemoryKind.METASPACE, myMetaspaceSizeLabel, myMetaspaceSizeField, myMetaspaceUnitsLabel, myMetaspaceCurrentValueLabel);
|
||||
configControls(MemoryKind.CODE_CACHE, myCodeCacheSizeLabel, myCodeCacheSizeField, myCodeCacheUnitsLabel, myCodeCacheCurrentValueLabel);
|
||||
|
||||
init();
|
||||
@@ -141,6 +138,12 @@ public class OutOfMemoryDialog extends DialogWrapper {
|
||||
}
|
||||
catch (NumberFormatException ignored) { }
|
||||
|
||||
try {
|
||||
int codeCacheSize = Integer.parseInt(myMetaspaceSizeField.getText());
|
||||
VMOptions.writeOption(MemoryKind.METASPACE, codeCacheSize);
|
||||
}
|
||||
catch (NumberFormatException ignored) { }
|
||||
|
||||
try {
|
||||
int codeCacheSize = Integer.parseInt(myCodeCacheSizeField.getText());
|
||||
VMOptions.writeOption(MemoryKind.CODE_CACHE, codeCacheSize);
|
||||
@@ -180,7 +183,7 @@ public class OutOfMemoryDialog extends DialogWrapper {
|
||||
@SuppressWarnings("Duplicates")
|
||||
private void enableControls(boolean enabled) {
|
||||
myHeapSizeField.setEnabled(enabled);
|
||||
myPermGenSizeField.setEnabled(enabled);
|
||||
myMetaspaceSizeField.setEnabled(enabled);
|
||||
myCodeCacheSizeField.setEnabled(enabled);
|
||||
myShutdownAction.setEnabled(enabled);
|
||||
myContinueAction.setEnabled(enabled);
|
||||
@@ -201,7 +204,7 @@ public class OutOfMemoryDialog extends DialogWrapper {
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myMemoryKind == MemoryKind.PERM_GEN ? myPermGenSizeField :
|
||||
return myMemoryKind == MemoryKind.METASPACE ? myMetaspaceSizeField :
|
||||
myMemoryKind == MemoryKind.CODE_CACHE ? myCodeCacheSizeField :
|
||||
myHeapSizeField;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class VMOptions {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.diagnostic.VMOptions");
|
||||
|
||||
public enum MemoryKind {
|
||||
HEAP("Xmx", ""), PERM_GEN("XX:MaxPermSize", "="), CODE_CACHE("XX:ReservedCodeCacheSize", "=");
|
||||
HEAP("Xmx", ""), PERM_GEN("XX:MaxPermSize", "="), METASPACE("XX:MaxMetaspaceSize", "="), CODE_CACHE("XX:ReservedCodeCacheSize", "=");
|
||||
|
||||
public final String optionName;
|
||||
public final String option;
|
||||
|
||||
@@ -846,7 +846,7 @@ action.LocalVcs.ShowStatistics.description=Show Local VCS statistics
|
||||
action.LocalVcs.ShowRepHistory.text=Repository History
|
||||
action.DropAnError.text=Drop An Error
|
||||
action.DropAnOutOfMemoryError.text=Drop An OutOfMemoryError
|
||||
action.DropAnOutOfPermGenMemoryError.text=Drop An PermGen OutOfMemoryError
|
||||
action.DropAnOutOfMetaspaceError.text=Drop an OutOfMemoryError in Metaspace
|
||||
action.DumpInspectionDescriptions.text=Dump Inspection Descriptions
|
||||
action.DumpIntentionsDescriptions.text=Dump Intentions Descriptions
|
||||
action.ShowUserActivities.text=Show Activities
|
||||
|
||||
@@ -709,7 +709,7 @@
|
||||
<action id="DropAnError" internal="true" class="com.intellij.diagnostic.DropAnErrorAction"/>
|
||||
<action id="DropAnErrorWithAttachments" internal="true" class="com.intellij.diagnostic.DropAnErrorWithAttachmentsAction"/>
|
||||
<action id="DropAnOutOfMemoryError" internal="true" class="com.intellij.diagnostic.DropAnOutOfMemoryErrorAction"/>
|
||||
<action id="DropAnOutOfPermGenMemoryError" internal="true" class="com.intellij.diagnostic.DropAnOutOfPermGenMemoryErrorAction"/>
|
||||
<action id="DropAnOutOfMetaspaceError" internal="true" class="com.intellij.diagnostic.DropAnOutOfMetaspaceErrorAction"/>
|
||||
</group>
|
||||
<separator/>
|
||||
<action internal="true" id="ReloadProjectAction" class="com.intellij.internal.ReloadProjectAction"/>
|
||||
|
||||
@@ -36,7 +36,7 @@ public class VMOptionsTest {
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
myFile = myTempDir.newFile("vmoptions.txt");
|
||||
FileUtil.writeToFile(myFile, "-Xmx512m\n-XX:MaxPermSize=128m");
|
||||
FileUtil.writeToFile(myFile, "-Xmx512m\n-XX:MaxMetaspaceSize=128m");
|
||||
System.setProperty("jb.vmOptionsFile", myFile.getPath());
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class VMOptionsTest {
|
||||
@Test
|
||||
public void testReading() {
|
||||
assertEquals(512, VMOptions.readOption(VMOptions.MemoryKind.HEAP, false));
|
||||
assertEquals(128, VMOptions.readOption(VMOptions.MemoryKind.PERM_GEN, false));
|
||||
assertEquals(128, VMOptions.readOption(VMOptions.MemoryKind.METASPACE, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -56,50 +56,50 @@ public class VMOptionsTest {
|
||||
FileUtil.writeToFile(myFile, "");
|
||||
|
||||
assertEquals(-1, VMOptions.readOption(VMOptions.MemoryKind.HEAP, false));
|
||||
assertEquals(-1, VMOptions.readOption(VMOptions.MemoryKind.PERM_GEN, false));
|
||||
assertEquals(-1, VMOptions.readOption(VMOptions.MemoryKind.METASPACE, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadingKilos() throws IOException {
|
||||
FileUtil.writeToFile(myFile, "-Xmx512000k -XX:MaxPermSize=128000K -XX:ReservedCodeCacheSize=256000K");
|
||||
FileUtil.writeToFile(myFile, "-Xmx512000k -XX:MaxMetaspaceSize=128000K -XX:ReservedCodeCacheSize=256000K");
|
||||
|
||||
assertEquals(512000 / 1024, VMOptions.readOption(VMOptions.MemoryKind.HEAP, false));
|
||||
assertEquals(128000 / 1024, VMOptions.readOption(VMOptions.MemoryKind.PERM_GEN, false));
|
||||
assertEquals(128000 / 1024, VMOptions.readOption(VMOptions.MemoryKind.METASPACE, false));
|
||||
assertEquals(256000 / 1024, VMOptions.readOption(VMOptions.MemoryKind.CODE_CACHE, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadingGigs() throws IOException {
|
||||
FileUtil.writeToFile(myFile, "-Xmx512g\n-XX:MaxPermSize=128G");
|
||||
FileUtil.writeToFile(myFile, "-Xmx512g\n-XX:MaxMetaspaceSize=128G");
|
||||
|
||||
assertEquals(512 * 1024, VMOptions.readOption(VMOptions.MemoryKind.HEAP, false));
|
||||
assertEquals(128 * 1024, VMOptions.readOption(VMOptions.MemoryKind.PERM_GEN, false));
|
||||
assertEquals(128 * 1024, VMOptions.readOption(VMOptions.MemoryKind.METASPACE, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadingWithoutUnit() throws IOException {
|
||||
FileUtil.writeToFile(myFile, "-Xmx512\n-XX:MaxPermSize=128");
|
||||
FileUtil.writeToFile(myFile, "-Xmx512\n-XX:MaxMetaspaceSize=128");
|
||||
|
||||
assertEquals(512, VMOptions.readOption(VMOptions.MemoryKind.HEAP, false));
|
||||
assertEquals(128, VMOptions.readOption(VMOptions.MemoryKind.PERM_GEN, false));
|
||||
assertEquals(128, VMOptions.readOption(VMOptions.MemoryKind.METASPACE, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriting() throws IOException {
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.HEAP, 1024);
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.PERM_GEN, 512);
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.METASPACE, 512);
|
||||
|
||||
assertThat(FileUtil.loadFile(myFile)).isEqualToIgnoringWhitespace("-Xmx1024m -XX:MaxPermSize=512m");
|
||||
assertThat(FileUtil.loadFile(myFile)).isEqualToIgnoringWhitespace("-Xmx1024m -XX:MaxMetaspaceSize=512m");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWritingPreservingLocation() throws IOException {
|
||||
FileUtil.writeToFile(myFile, "-someOption\n-Xmx512m\n-XX:MaxPermSize=128m\n-anotherOption");
|
||||
FileUtil.writeToFile(myFile, "-someOption\n-Xmx512m\n-XX:MaxMetaspaceSize=128m\n-anotherOption");
|
||||
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.HEAP, 1024);
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.PERM_GEN, 256);
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.METASPACE, 256);
|
||||
|
||||
assertThat(FileUtil.loadFile(myFile)).isEqualToIgnoringWhitespace("-someOption -Xmx1024m -XX:MaxPermSize=256m -anotherOption");
|
||||
assertThat(FileUtil.loadFile(myFile)).isEqualToIgnoringWhitespace("-someOption -Xmx1024m -XX:MaxMetaspaceSize=256m -anotherOption");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -107,10 +107,10 @@ public class VMOptionsTest {
|
||||
FileUtil.writeToFile(myFile, "-someOption");
|
||||
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.HEAP, 1024);
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.PERM_GEN, 256);
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.METASPACE, 256);
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.CODE_CACHE, 256);
|
||||
|
||||
assertThat(FileUtil.loadFile(myFile)).isEqualToIgnoringWhitespace("-someOption -Xmx1024m -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=256m");
|
||||
assertThat(FileUtil.loadFile(myFile)).isEqualToIgnoringWhitespace("-someOption -Xmx1024m -XX:MaxMetaspaceSize=256m -XX:ReservedCodeCacheSize=256m");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,9 +118,9 @@ public class VMOptionsTest {
|
||||
FileUtil.setReadOnlyAttribute(myFile.getPath(), true);
|
||||
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.HEAP, 1024);
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.PERM_GEN, 256);
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.METASPACE, 256);
|
||||
|
||||
assertThat(FileUtil.loadFile(myFile)).isEqualToIgnoringWhitespace("-Xmx1024m -XX:MaxPermSize=256m");
|
||||
assertThat(FileUtil.loadFile(myFile)).isEqualToIgnoringWhitespace("-Xmx1024m -XX:MaxMetaspaceSize=256m");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,8 +128,8 @@ public class VMOptionsTest {
|
||||
FileUtil.delete(myFile);
|
||||
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.HEAP, 1024);
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.PERM_GEN, 256);
|
||||
VMOptions.writeOption(VMOptions.MemoryKind.METASPACE, 256);
|
||||
|
||||
assertThat(FileUtil.loadFile(myFile)).isEqualToIgnoringWhitespace("-Xmx1024m -XX:MaxPermSize=256m");
|
||||
assertThat(FileUtil.loadFile(myFile)).isEqualToIgnoringWhitespace("-Xmx1024m -XX:MaxMetaspaceSize=256m");
|
||||
}
|
||||
}
|
||||
@@ -344,6 +344,7 @@ mediumint
|
||||
mediumtext
|
||||
metadata
|
||||
metas
|
||||
metaspace
|
||||
middleint
|
||||
middleware
|
||||
millis
|
||||
|
||||
Reference in New Issue
Block a user