Skip to content

Commit

Permalink
563960: Requested length of new long[2,147,483,640] exceeds limit of
Browse files Browse the repository at this point in the history
2,147,483,639

Show discard ratio on heap dump info

Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=563960

Change-Id: Id159c172f7e59296b620f340709a6c04980a015e
  • Loading branch information
ajohnson1 committed Oct 18, 2020
1 parent e75b837 commit ceaf6a4
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import org.eclipse.mat.util.MessageUtil;
import org.eclipse.mat.util.Units;

import com.ibm.icu.text.NumberFormat;

@Category(Category.HIDDEN)
@CommandName("heap_dump_overview")
@Icon("/META-INF/icons/heapdump_details.gif")
Expand Down Expand Up @@ -146,6 +148,28 @@ public IResult execute(IProgressListener listener) throws Exception
{
entries.add(new TextEntry(Messages.HeapDumpInfoQuery_MultipleSnapshotIdentifier, identifier.toString()));
}
NumberFormat percentFormatter = NumberFormat.getPercentInstance();
percentFormatter.setMaximumFractionDigits(0);
Serializable discard_ratio = info.getProperty("discard_ratio"); //$NON-NLS-1$
if (discard_ratio instanceof Integer)
{
entries.add(new TextEntry(Messages.HeapDumpInfoQuery_DiscardRatio, MessageUtil.format(Messages.HeapDumpInfoQuery_DiscardRatio_format, percentFormatter.format((Integer)discard_ratio * 0.01))));
}
Serializable discard_pattern = info.getProperty("discard_pattern"); //$NON-NLS-1$
if (discard_pattern instanceof String)
{
entries.add(new TextEntry(Messages.HeapDumpInfoQuery_DiscardPattern, discard_pattern.toString()));
}
Serializable discard_offset = info.getProperty("discard_offset"); //$NON-NLS-1$
if (discard_offset instanceof Integer)
{
entries.add(new TextEntry(Messages.HeapDumpInfoQuery_DiscardOffset, MessageUtil.format(Messages.HeapDumpInfoQuery_DiscardOffset_format, percentFormatter.format((Integer)discard_offset * 0.01))));
}
Serializable discard_seed = info.getProperty("discard_seed"); //$NON-NLS-1$
if (discard_seed instanceof Integer)
{
entries.add(new TextEntry(Messages.HeapDumpInfoQuery_DiscardSeed, MessageUtil.format(Messages.HeapDumpInfoQuery_DiscardSeed_format, discard_seed)));
}

return new ListResult(TextEntry.class, entries, "propertyName", "propertyValue"); //$NON-NLS-1$ //$NON-NLS-2$
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,14 @@ public class Messages extends NLS
public static String HeapDumpInfoQuery_Column_Time;
public static String HeapDumpInfoQuery_Column_UsedHeapDump;
public static String HeapDumpInfoQuery_DateFormat;
public static String HeapDumpInfoQuery_DiscardOffset;
public static String HeapDumpInfoQuery_DiscardOffset_format;
public static String HeapDumpInfoQuery_DiscardPattern;
public static String HeapDumpInfoQuery_DiscardRatio;
public static String HeapDumpInfoQuery_DiscardRatio_format;
public static String HeapDumpInfoQuery_DiscardSeed;
public static String HeapDumpInfoQuery_DiscardSeed_format;
public static String HeapDumpInfoQuery_FileLengthFormat;

public static String HeapDumpInfoQuery_MultipleSnapshotIdentifier;
public static String HeapDumpInfoQuery_NumClassesFormat;
public static String HeapDumpInfoQuery_NumClassLoadersFormat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ HeapDumpInfoQuery_Column_Time=Time
HeapDumpInfoQuery_TimeFormat={0,time,long}
HeapDumpInfoQuery_Column_Date=Date
HeapDumpInfoQuery_DateFormat={0,date}
HeapDumpInfoQuery_DiscardOffset=Discard offset percentage
HeapDumpInfoQuery_DiscardOffset_format={0}
HeapDumpInfoQuery_DiscardPattern=Discard object type pattern
HeapDumpInfoQuery_DiscardRatio=Discard percentage
HeapDumpInfoQuery_DiscardRatio_format={0}
HeapDumpInfoQuery_DiscardSeed=Discard random seed
HeapDumpInfoQuery_DiscardSeed_format={0}
HeapDumpInfoQuery_Column_FilePath=File path
HeapDumpInfoQuery_Column_FileLength=File length
HeapDumpInfoQuery_Column_IdentifierSize=Identifier size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,25 @@ protected void updateSnapshotInput()
category.addChild(new Label(Messages.identifier, info.getProperty("$runtimeId"), bInfo //$NON-NLS-1$
.getProperty("$runtimeId"))); //$NON-NLS-1$
}
Serializable discard_ratio = info.getProperty("discard_ratio"); //$NON-NLS-1$
Serializable bDiscard_ratio = bInfo.getProperty("discard_ratio"); //$NON-NLS-1$
if (discard_ratio instanceof Integer && (Integer)discard_ratio != 0 ||
bDiscard_ratio instanceof Integer && (Integer)bDiscard_ratio != 0)
{
category.addChild(new Label(org.eclipse.mat.ui.Messages.UIPreferencePage_DiscardPercentage, discard_ratio, bDiscard_ratio));

Serializable discard_pattern = info.getProperty("discard_pattern"); //$NON-NLS-1$
Serializable bDiscard_pattern = bInfo.getProperty("discard_pattern"); //$NON-NLS-1$
category.addChild(new Label(org.eclipse.mat.ui.Messages.UIPreferencePage_DiscardPattern, discard_pattern, bDiscard_pattern));

Serializable discard_offset = info.getProperty("discard_offset"); //$NON-NLS-1$
Serializable bDiscard_offset = bInfo.getProperty("discard_offset"); //$NON-NLS-1$
category.addChild(new Label(org.eclipse.mat.ui.Messages.UIPreferencePage_DiscardOffset, discard_offset, bDiscard_offset));

Serializable discard_seed = info.getProperty("discard_seed"); //$NON-NLS-1$
Serializable bDiscard_seed = bInfo.getProperty("discard_seed"); //$NON-NLS-1$
category.addChild(new Label(org.eclipse.mat.ui.Messages.UIPreferencePage_DiscardSeed, discard_seed, bDiscard_seed));
}

category = new Category(Messages.statistic_info);
elements.add(category);
Expand All @@ -365,6 +384,7 @@ protected void updateSnapshotInput()
category.addChild(new Label(Messages.unreachable_heap, u[1], bU[1]));
category.addChild(new Label(Messages.number_of_unreachable_objects, unreachableObjects, bUnreachableObjects));
}

}
else if (getSnapshotPath() != null)
{
Expand Down

0 comments on commit ceaf6a4

Please sign in to comment.