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
diff --git a/android/module.go b/android/module.go
index ecd0f23..c0abfd0 100644
--- a/android/module.go
+++ b/android/module.go
@@ -45,6 +45,14 @@
// 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 @@
})
}
}
+
+ m.module.CleanupAfterBuildActions()
}
+func (m *ModuleBase) CleanupAfterBuildActions() {}
+
func SetJarJarPrefixHandler(handler func(ModuleContext)) {
if jarJarPrefixHandler != nil {
panic("jarJarPrefixHandler already set")