From 90db3a16b79470f4b67a4e3c008f98f9c90e0326 Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Tue, 7 Jan 2014 13:53:03 -0800 Subject: [PATCH] Lazily create the lists in MethodLocation Millions of MethodLocations can be created and kept in memory when using the Builder interface to build a large dex file. The arrays backing these lists were taking up a large amount of memory. --- .../jf/dexlib2/builder/MethodLocation.java | 81 +++++++++++++------ 1 file changed, 58 insertions(+), 23 deletions(-) diff --git a/dexlib2/src/main/java/org/jf/dexlib2/builder/MethodLocation.java b/dexlib2/src/main/java/org/jf/dexlib2/builder/MethodLocation.java index f7c0effc..5a707e92 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/builder/MethodLocation.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/builder/MethodLocation.java @@ -31,7 +31,7 @@ package org.jf.dexlib2.builder; -import com.google.common.collect.Lists; +import com.google.common.collect.ImmutableList; import org.jf.dexlib2.builder.debug.*; import org.jf.dexlib2.iface.instruction.Instruction; import org.jf.dexlib2.iface.reference.StringReference; @@ -39,18 +39,21 @@ import org.jf.dexlib2.iface.reference.TypeReference; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.AbstractSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; +import java.util.*; public class MethodLocation { @Nullable BuilderInstruction instruction; int codeAddress; int index; - private List