staticcheck SA4023 peak memory since v2.13
Welcome
- Yes, I'm using a binary release within 2 latest releases. Only such installations are supported.
- Yes, I've searched similar issues on GitHub and didn't find any.
- Yes, I've read the
typechecksection of the FAQ. - Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.).
- I agree to follow this project's Code of Conduct
How did you install golangci-lint?
Official binary
Description of the problem
Since golangci-lint v2.13.0 (staticcheck 2026.2, where SA4023 was reimplemented), the memory attributable to SA4023 more than doubled. On our private monorepo (4,148 packages, 5,588 including deps), golangci-lint run started getting OOM-killed on a 16 GiB CI runner after upgrading from v2.12.2. Disabling SA4023 alone fixes it.
Standalone staticcheck 2026.2.1 on the same private repo does not show this: peak live heap is ~1.0-1.2 GB with or without SA4023. So the growth seems specific to how facts are handled in golangci-lint.
Public reproduction with kubernetes v1.36.5 (go 1.26.0), staticcheck only, Go 1.26.1, --concurrency 8, empty cache each run. Peak live heap is the maximum post-GC heap from GODEBUG=gctrace=1 (average of 2 runs):
| golangci-lint | SA4023 enabled | SA4023 disabled | SA4023 cost |
|---|---|---|---|
| v2.12.2 (staticcheck 0.7.0) | 4,861 MB | 4,129 MB | +732 MB |
| v2.14.0 (staticcheck 0.8.1) | 4,926 MB | 3,205 MB | +1,721 MB |
On kubernetes the total stays about the same because the rest of staticcheck got cheaper. On our repo it does not cancel out, and the total grew from 6.8 GB to 8.2 GB (GC goal 13.6 GB to 16.4 GB):
| Our repo, full config | SA4023 enabled | SA4023 disabled |
|---|---|---|
| v2.12.2 | 6,813 MB | 5,338 MB |
| v2.13.2 | 8,181-8,262 MB | 4,864-5,036 MB |
With --mem-profile-path (alloc_space, v2.13.2), goanalysis.inheritFacts goes from 7.1 GB to 22.3 GB when SA4023 is enabled, and honnef.co/go/tools/analysis/facts/nilness.run adds 8.1 GB.
Version of golangci-lint
golangci-lint has version 2.14.0 built with go1.27.0 from 114493f9 on 2026-09-24T11:07:15Z
Configuration
version: "2"
linters:
default: none
enable:
- staticcheck
# for the "SA4023 disabled" runs:
# settings:
# staticcheck:
# checks: ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-SA4023"]Go environment
go version go1.26.1 darwin/arm64(Full go env omitted; default settings, GOTOOLCHAIN pinned to go1.26.1.)
Verbose output of running
Output of golangci-lint cache clean && golangci-lint run -v on kubernetes v1.36.5 with SA4023 enabled (max_same_issues lines omitted, paths redacted):
level=info msg="golangci-lint has version 2.14.0 built with go1.27.0 from 114493f9 on 2026-09-24T11:07:15Z"
level=info msg="[config_reader] Used config file .golangci.yml"
level=info msg="[config_reader] Module name \"k8s.io/kubernetes\""
level=info msg="[goenv] Read go env for 85.880708ms: map[string]string{\"GOCACHE\":\"<path>", \"GOROOT\":\"<path>"}"
level=info msg="[lintersdb] Active 1 linters: [staticcheck]"
level=info msg="[loader] Go packages loading at mode 8767 (exports_file|imports|name|types_sizes|deps|files|compiled_files) took 4.693854583s"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 218.035292ms"
level=info msg="[linters_context/goanalysis] analyzers took 2m35.380155956s with top 10 stages: nilness: 33.619161707s, buildir: 20.583117403s, fact_purity: 5.861908618s, fact_deprecated: 5.009317586s, SA5012: 3.77816114s, ctrlflow: 3.25456049s, S1038: 3.007174724s, S1008: 1.683429772s, QF1008: 1.625291711s, QF1010: 1.467619029s"
level=info msg="[runner/max_from_linter] 391/441 issues from linter staticcheck were hidden, use --max-issues-per-linter"
level=info msg="[runner] Issues before processing: 7159, after processing: 50"
level=info msg="[runner] linters took 15.104930959s with stages: goanalysis_metalinter: 14.7805925s"
level=info msg="File cache stats: 31 entries of total size 834.3KiB"
level=info msg="Memory: 201 samples, avg is 3773.1MB, max is 9913.5MB"
level=info msg="Execution took 20.107422s"A minimal reproducible example or link to a public repository
git clone --depth 1 --branch v1.36.5 https://github.com/kubernetes/kubernetes.git && cd kubernetes
GODEBUG=gctrace=1 golangci-lint run -c with.yml --concurrency 8 ./... 2> with.log
GODEBUG=gctrace=1 golangci-lint run -c without.yml --concurrency 8 ./... 2> without.log
# peak live heap = max of the third number in "X->Y->Z MB"
grep -oE '[0-9]+->[0-9]+->[0-9]+ MB' with.log | awk -F'->' '{split($3,a," "); if(a[1]>m)m=a[1]} END{print m}'Validation
- Yes, I've included all the information above (example, version, config, etc.).
Supporter
- I am a sponsor/backer of this project.
Source: golangci/golangci-lint