Skip to content

Commit

Permalink
Drop memory usage of go/analysis linters 5x
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jirfag committed Sep 23, 2019
1 parent 4929718 commit 2fc8b7b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/golinters/goanalysis/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,13 @@ func (lp *loadingPackage) decUse() {
pass.ImportPackageFact = nil
pass.ExportPackageFact = nil
act.pass = nil
act.deps = nil
if act.result != nil {
if isMemoryDebug {
debugf("%s: decUse: nilling act result of size %d bytes", act, sizeOfValueTreeBytes(act.result))
}
act.result = nil
}
}

lp.pkg.Syntax = nil
Expand Down Expand Up @@ -899,13 +906,6 @@ func (lp *loadingPackage) decUse() {
}
act.packageFacts = nil
act.objectFacts = nil
act.deps = nil
if act.result != nil {
if isMemoryDebug {
debugf("%s: decUse: nilling act result of size %d bytes", act, sizeOfValueTreeBytes(act.result))
}
act.result = nil
}
}
lp.actions = nil
}
Expand Down

0 comments on commit 2fc8b7b

Please sign in to comment.