mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[memory-agent] Do not estimate the retained size of too many objects (more than 2000)
This commit is contained in:
@@ -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<JavaReferenceInfo> tryCalculateSizes(@NotNull List<JavaReferenceInfo> 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())
|
||||
|
||||
Reference in New Issue
Block a user