From b790b9cb8f891bf21755ccc97a5405b2ed0687d2 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 19 Mar 2025 14:12:09 -0700 Subject: 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 --- cc/cc.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'cc') diff --git a/cc/cc.go b/cc/cc.go index 85d2ebfbb..c616165c5 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -2438,6 +2438,27 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } } +func (c *Module) CleanupAfterBuildActions() { + // Clear as much of Module as possible to reduce memory usage. + c.generators = nil + c.compiler = nil + c.installer = nil + c.features = nil + c.coverage = nil + c.fuzzer = nil + c.sabi = nil + c.lto = nil + c.afdo = nil + c.orderfile = nil + + // TODO: these can be cleared after nativeBinaryInfoProperties and nativeLibInfoProperties are switched to + // using providers. + // c.linker = nil + // c.stl = nil + // c.sanitize = nil + // c.library = nil +} + func CreateCommonLinkableInfo(ctx android.ModuleContext, mod VersionedLinkableInterface) *LinkableInfo { info := &LinkableInfo{ StaticExecutable: mod.StaticExecutable(), -- cgit v1.2.3-59-g8ed1b