aboutsummaryrefslogtreecommitdiffhomepage
path: root/transform/allocs.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2022-04-19 15:31:23 +0200
committerRon Evans <[email protected]>2022-05-30 07:53:28 +0200
commit777d3f3ea5a570615b615e323c977f73d6674507 (patch)
treeac5bf4b4e169f37b81cec5dfcddfc6e1b0814899 /transform/allocs.go
parentea3b5dc68979da59e6a62ed64bce7369ad1f0e22 (diff)
downloadtinygo-777d3f3ea5a570615b615e323c977f73d6674507.tar.gz
tinygo-777d3f3ea5a570615b615e323c977f73d6674507.zip
builder: free LLVM objects after use
This reduces the TinyGo memory consumption when running make tinygo-test from 5.8GB to around 2GB on my laptop.
Diffstat (limited to 'transform/allocs.go')
-rw-r--r--transform/allocs.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/transform/allocs.go b/transform/allocs.go
index 35fa1b0bb..af7c70b28 100644
--- a/transform/allocs.go
+++ b/transform/allocs.go
@@ -36,8 +36,10 @@ func OptimizeAllocs(mod llvm.Module, printAllocs *regexp.Regexp, logger func(tok
}
targetData := llvm.NewTargetData(mod.DataLayout())
+ defer targetData.Dispose()
i8ptrType := llvm.PointerType(mod.Context().Int8Type(), 0)
builder := mod.Context().NewBuilder()
+ defer builder.Dispose()
for _, heapalloc := range getUses(allocator) {
logAllocs := printAllocs != nil && printAllocs.MatchString(heapalloc.InstructionParent().Parent().Name())