Revert: "Collect dead dex items after tree shaking"

Bug: b/446202198
Change-Id: I60aecc6e14ca46c188aec963d6f54bd9b5b053fc
Reason for revert: Regresses studio-main build speed benchmarks
diff --git a/src/main/java/com/android/tools/r8/graph/DexItemFactory.java b/src/main/java/com/android/tools/r8/graph/DexItemFactory.java
index ad567ab..b880ca8 100644
--- a/src/main/java/com/android/tools/r8/graph/DexItemFactory.java
+++ b/src/main/java/com/android/tools/r8/graph/DexItemFactory.java
@@ -53,7 +53,6 @@
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
-import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.function.Consumer;
 import java.util.function.Function;
@@ -3668,37 +3667,6 @@
     allTypes.forEach(f);
   }
 
-  public void gc() {
-    markers = new WeakHashMap<>(markers);
-    methodHandles = new WeakHashMap<>(methodHandles);
-    strings = new WeakHashMap<>(strings);
-    types = new WeakHashMap<>(types);
-    fields = new WeakHashMap<>(fields);
-    protos = new WeakHashMap<>(protos);
-    methods = new WeakHashMap<>(methods);
-    committedMethodHandles = new WeakHashMap<>(committedMethodHandles);
-    committedStrings = new WeakHashMap<>(committedStrings);
-    committedTypes = new WeakHashMap<>(committedTypes);
-    committedFields = new WeakHashMap<>(committedFields);
-    committedProtos = new WeakHashMap<>(committedProtos);
-    committedMethods = new WeakHashMap<>(committedMethods);
-    System.gc();
-    System.gc();
-    markers = new ConcurrentHashMap<>(markers);
-    methodHandles = new ConcurrentHashMap<>(methodHandles);
-    strings = new ConcurrentHashMap<>(strings);
-    types = new ConcurrentHashMap<>(types);
-    fields = new ConcurrentHashMap<>(fields);
-    protos = new ConcurrentHashMap<>(protos);
-    methods = new ConcurrentHashMap<>(methods);
-    committedMethodHandles = new HashMap<>(committedMethodHandles);
-    committedStrings = new HashMap<>(committedStrings);
-    committedTypes = new HashMap<>(committedTypes);
-    committedFields = new HashMap<>(committedFields);
-    committedProtos = new HashMap<>(committedProtos);
-    committedMethods = new HashMap<>(committedMethods);
-  }
-
   public void commitPendingItems() {
     commitPendingItems(committedMethodHandles, methodHandles);
     commitPendingItems(committedStrings, strings);
diff --git a/src/main/java/com/android/tools/r8/shaking/TreePruner.java b/src/main/java/com/android/tools/r8/shaking/TreePruner.java
index b17e643..5c629c0 100644
--- a/src/main/java/com/android/tools/r8/shaking/TreePruner.java
+++ b/src/main/java/com/android/tools/r8/shaking/TreePruner.java
@@ -96,7 +96,6 @@
     appView.pruneItems(prunedItems, executorService, timing);
     appView.notifyOptimizationFinishedForTesting();
     timing.end();
-    appView.dexItemFactory().gc();
   }
 
   private DirectMappedDexApplication.Builder removeUnused(DirectMappedDexApplication application) {