summaryrefslogtreecommitdiff
path: root/android/module.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2025-03-19 14:12:09 -0700
committer Colin Cross <ccross@android.com> 2025-03-19 16:25:18 -0700
commitb790b9cb8f891bf21755ccc97a5405b2ed0687d2 (patch)
tree2f62bf7fc1ae74688bfd98113a61cc6bef87e1af /android/module.go
parent80f92da0efc1924aa30866e64b266d1dee87aa51 (diff)
Clear as much of cc.Module as possible after GenerateBuildActions
Reduce peak memory usage by adding a CleanupAfterBuildActions method that is called at the end GenerateBuidlActions, nad use it to clear as much of cc.Module as possible. This is a temporary measure, eventually the entire module should be released by blueprint once all interactions are performed through providers. Test: all soong tests pass Change-Id: Idc3390ae4506ff2eef3231691e1de7446067961a
Diffstat (limited to 'android/module.go')
-rw-r--r--android/module.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/android/module.go b/android/module.go
index ecd0f239c..c0abfd0a3 100644
--- a/android/module.go
+++ b/android/module.go
@@ -45,6 +45,14 @@ type Module interface {
// For more information, see Module.GenerateBuildActions within Blueprint's module_ctx.go
GenerateAndroidBuildActions(ModuleContext)
+ // CleanupAfterBuildActions is called after ModuleBase.GenerateBuildActions is finished.
+ // If all interactions with this module are handled via providers instead of direct access
+ // to the module then it can free memory attached to the module.
+ // This is a temporary measure to reduce memory usage, eventually blueprint's reference
+ // to the Module should be dropped after GenerateAndroidBuildActions once all accesses
+ // can be done through providers.
+ CleanupAfterBuildActions()
+
// Add dependencies to the components of a module, i.e. modules that are created
// by the module and which are considered to be part of the creating module.
//
@@ -2387,8 +2395,12 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
})
}
}
+
+ m.module.CleanupAfterBuildActions()
}
+func (m *ModuleBase) CleanupAfterBuildActions() {}
+
func SetJarJarPrefixHandler(handler func(ModuleContext)) {
if jarJarPrefixHandler != nil {
panic("jarJarPrefixHandler already set")