Skip to content

Commit 96ab61b

Browse files
committed
Drop memory usage of go/analysis linters 5x
Set analysis pass results to nil early to garbage collect them soon. Memory can be reduced for the following linters: - staticcheck - stylecheck - gosimple - govet - bodyclose - any future go/analysis linter Relates: #712, #634, #628, #598, #509, #483, #337
1 parent 4929718 commit 96ab61b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pkg/golinters/goanalysis/runner.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,13 @@ func (lp *loadingPackage) decUse() {
872872
pass.ImportPackageFact = nil
873873
pass.ExportPackageFact = nil
874874
act.pass = nil
875+
act.deps = nil
876+
if act.result != nil {
877+
if isMemoryDebug {
878+
debugf("%s: decUse: nilling act result of size %d bytes", act, sizeOfValueTreeBytes(act.result))
879+
}
880+
act.result = nil
881+
}
875882
}
876883

877884
lp.pkg.Syntax = nil
@@ -899,13 +906,6 @@ func (lp *loadingPackage) decUse() {
899906
}
900907
act.packageFacts = nil
901908
act.objectFacts = nil
902-
act.deps = nil
903-
if act.result != nil {
904-
if isMemoryDebug {
905-
debugf("%s: decUse: nilling act result of size %d bytes", act, sizeOfValueTreeBytes(act.result))
906-
}
907-
act.result = nil
908-
}
909909
}
910910
lp.actions = nil
911911
}

0 commit comments

Comments
 (0)