Don't retain memory used by Artifact->owner Label multimap after it's been used at the start of execution.
PiperOrigin-RevId: 206230049
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
index d31e0d1..44a5fd7 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
@@ -302,8 +302,6 @@
Set<AspectKey> builtAspects = new HashSet<>();
Collection<AspectValue> aspects = analysisResult.getAspects();
- SetMultimap<Artifact, Label> topLevelArtifactsToOwnerLabels =
- TopLevelArtifactHelper.makeTopLevelArtifactsToOwnerLabels(analysisResult, aspects);
if (request.isRunningInEmacs()) {
// The syntax of this message is tightly constrained by lisp/progmodes/compile.el in emacs
request
@@ -313,12 +311,16 @@
}
boolean buildCompleted = false;
try {
+ SetMultimap<Artifact, Label> topLevelArtifactsToOwnerLabels =
+ TopLevelArtifactHelper.makeTopLevelArtifactsToOwnerLabels(analysisResult, aspects);
for (ActionContextProvider actionContextProvider : actionContextProviders) {
try (SilentCloseable c =
Profiler.instance().profile(actionContextProvider + ".executionPhaseStarting")) {
actionContextProvider.executionPhaseStarting(actionGraph, topLevelArtifactsToOwnerLabels);
}
}
+ // Don't retain memory.
+ topLevelArtifactsToOwnerLabels = null;
executor.executionPhaseStarting();
skyframeExecutor.drainChangedFiles();