From 20547a9f59ceec9c8a5a3c5b7e92c93689a10667 Mon Sep 17 00:00:00 2001 From: "Vitaliy.Bibaev" Date: Mon, 11 Feb 2019 18:53:18 +0300 Subject: [PATCH] [memory-agent] Do not estimate the retained size of too many objects (more than 2000) --- .../com/intellij/debugger/memory/agent/MemoryAgentUtil.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/debugger/impl/src/com/intellij/debugger/memory/agent/MemoryAgentUtil.java b/java/debugger/impl/src/com/intellij/debugger/memory/agent/MemoryAgentUtil.java index 047ba42e4d20..6ce8c7827d12 100644 --- a/java/debugger/impl/src/com/intellij/debugger/memory/agent/MemoryAgentUtil.java +++ b/java/debugger/impl/src/com/intellij/debugger/memory/agent/MemoryAgentUtil.java @@ -36,6 +36,7 @@ import java.util.jar.Attributes; public class MemoryAgentUtil { private static final Logger LOG = Logger.getInstance(MemoryAgentUtil.class); + private static final int ESTIMATE_OBJECTS_SIZE_LIMIT = 2000; public static void addMemoryAgent(@NotNull JavaParameters parameters) { if (!DebuggerSettings.getInstance().ENABLE_MEMORY_AGENT) { @@ -83,6 +84,10 @@ public class MemoryAgentUtil { public static List tryCalculateSizes(@NotNull List objects, @Nullable MemoryAgent agent) { if (agent == null || !agent.canEvaluateObjectsSizes()) return objects; + if (objects.size() > ESTIMATE_OBJECTS_SIZE_LIMIT) { + LOG.info("Too many objects to estimate their sizess"); + return objects; + } try { long[] sizes = agent.evaluateObjectsSizes(ContainerUtil.map(objects, x -> x.getObjectReference())); return IntStreamEx.range(0, objects.size())