Looking at proc-10451, I see that there are two mappings with anonymous huge pages in that smaps output, and none on the other. Does one machine have transparent hugepages enabled, and the other not? You can check whether they're enabled on that system by looking at /sys/kernel/mm/transparent_hugepage/enabled.
Here are the relevant smaps sections: c000000000-c000400000 rw-p 00000000 00:00 0 Size: 4096 kB KernelPageSize: 4 kB MMUPageSize: 4 kB Rss: 2048 kB Pss: 2048 kB Shared_Clean: 0 kB Shared_Dirty: 0 kB Private_Clean: 0 kB Private_Dirty: 2048 kB Referenced: 2048 kB Anonymous: 2048 kB LazyFree: 0 kB AnonHugePages: 2048 kB ShmemPmdMapped: 0 kB Shared_Hugetlb: 0 kB Private_Hugetlb: 0 kB Swap: 0 kB SwapPss: 0 kB Locked: 0 kB VmFlags: rd wr mr mw me ac sd 7f716a5e2000-7f716c953000 rw-p 00000000 00:00 0 Size: 36292 kB KernelPageSize: 4 kB MMUPageSize: 4 kB Rss: 2092 kB Pss: 2092 kB Shared_Clean: 0 kB Shared_Dirty: 0 kB Private_Clean: 0 kB Private_Dirty: 2092 kB Referenced: 2092 kB Anonymous: 2092 kB LazyFree: 0 kB AnonHugePages: 2048 kB ShmemPmdMapped: 0 kB Shared_Hugetlb: 0 kB Private_Hugetlb: 0 kB Swap: 0 kB SwapPss: 0 kB Locked: 0 kB VmFlags: rd wr mr mw me ac sd On Fri, Apr 29, 2022 at 12:18 PM garenchan <garencha...@gmail.com> wrote: > *What version of Go are you using (go version)?* > > $ go version > go version go1.17.6 linux/amd64 > > *Does this issue reproduce with the latest release?* > > uncertain > > *What operating system and processor architecture are you using (go env)?* > > $ go env > GO111MODULE="on" > GOARCH="amd64" > GOBIN="" > GOCACHE="/root/.cache/go-build" > GOENV="/root/.config/go/env" > GOEXE="" > GOEXPERIMENT="" > GOFLAGS="" > GOHOSTARCH="amd64" > GOHOSTOS="linux" > GOINSECURE="" > GOMODCACHE="/root/go/pkg/mod" > GONOPROXY="" > GONOSUMDB="" > GOOS="linux" > GOPATH="/root/go" > GOPRIVATE="" > GOPROXY="" > GOROOT="/home/go" > GOSUMDB="off" > GOTMPDIR="" > GOTOOLDIR="/home/go/pkg/tool/linux_amd64" > GOVCS="" > GOVERSION="go1.17.6" > GCCGO="gccgo" > AR="ar" > CC="gcc" > CXX="g++" > CGO_ENABLED="1" > GOMOD="/home/demo/go.mod" > CGO_CFLAGS="-g -O2" > CGO_CPPFLAGS="" > CGO_CXXFLAGS="-g -O2" > CGO_FFLAGS="-g -O2" > CGO_LDFLAGS="-g -O2" > PKG_CONFIG="pkg-config" > GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 > -fdebug-prefix-map=/tmp/go-build4023324410=/tmp/go-build > -gno-record-gcc-switches" > > *What did you do?* > > I encountered a memory problem with the GO program, see here for details.( > https://stackoverflow.com/questions/71994609/memory-footprint-of-the-same-program-varies-greatly-in-two-similar-environments > ) > > In order to simplify the analysis, I wrote a simple program to test. > > ```go > package main > > import ( > "time" > ) > > func main() { > time.Sleep(60*time.Second) > } > ``` > > > - I compiled it into binary file on a linux host `host1` with kernel > 4.18. Then I run it on `host1` and the process takes up close to 5MB RSS. > - I then copy the binary file to another host `host2` with kernel > 4.18. I also ran it on `host2`, but this time the process took up less than > 1MB RSS. > - I repeated the test many times and observed the same thing. > > > ``` > $ uname -a > Linux host1 4.18.0 #1 SMP Wed Nov 10 20:46:19 CST 2021 x86_64 x86_64 > x86_64 GNU/Linux > > $ uname -a > Linux host2 4.18.0 #1 SMP Fri May 8 10:59:10 UTC 2021 x86_64 x86_64 x86_64 > GNU/Linux > ``` > > Why is memory footprint of the same program in similar environments so > different? What factors might be contributing to this problem? > > *What did you expect to see?* > > I would expect to see the memory footprint of the same program in similar > environments be close. I look forward to your answers. Thank you very much. > > -- > 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 on the web visit > https://groups.google.com/d/msgid/golang-nuts/daba9d60-7c45-45f3-83c8-afc2471841c6n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/daba9d60-7c45-45f3-83c8-afc2471841c6n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 on the web visit https://groups.google.com/d/msgid/golang-nuts/CANrC0BjT-BHaryaMCiLiAfKbQmm%2ByZ4KYWHUUmb-8nhOE0bmcA%40mail.gmail.com.