Thanks for pointing me in that direction, this definitely contributes. I locally replaced golang.org/x/net with a version that does not use html/template and now the RSS of my program is down to 7588 KB. So there's still quite a bit of delta to what it was before importing grpc. As I can't really see anything with pprof I assume this is mostly down to init()? I just found out about GODEBUG=inittrace=1 so I counted those allocations up and got to ~2625 KB:
$ GODEBUG=inittrace=1 go run . &| awk '{b+=$8} END {print b}' 2625600 Now there's still around 3275 KB unaccounted for. Cyrill On Sunday, August 24, 2025 at 2:43:10 AM UTC+2 Ian Lance Taylor wrote: > On Sat, Aug 23, 2025 at 5:09 PM Cyrill Troxler <cyrill...@gmail.com> > wrote: > > > > I noticed that simply importing certain modules can substantially > increase observed RSS even though nothing is visibly being allocated on the > heap when looking at pprof. For example, take the following program: > > > > ``` > > package main > > > > import ( > > "time" > > ) > > > > func main() { > > time.Sleep(time.Hour) > > } > > ``` > > > > Running this with go 1.24.6 and running it shows an RSS of 1688 KB > (using ps). > > > > ``` > > VSZ RSS > > 1225172 1688 > > ``` > > > > Now as an example, I just add the following import: `_ " > google.golang.org/grpc"` > > > > The RSS of the otherwise same program looks like this: > > > > ``` > > VSZ RSS > > 1646164 9896 > > ``` > > > > First off, what exactly is causing this rather big increase in RSS here? > Is there any way to reduce this and if not, what is the best way to find > such heavy dependencies? > > > > I have used https://github.com/Zxilly/go-size-analyzer with some > success but this just looks at the binary size and is not very granular, > e.g. I have no way of knowing what exactly inside of the grpc module is > causing this. > > I didn't double check, but this could be a version of > https://go.dev/issue/62024. > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/8221cea6-b4da-4748-8cff-0d6c24244d1en%40googlegroups.com.