One of the reasons why Go program RSS is relatively large

Description of the problem: The program memory has not dropped after increasing from 1G to 5G

Checking the source code of go1.14, I found that: it says that there is a bug in the linux kernel, and the kernel version where I have the problem is 3.10

There is a description in libexec/src/runtime/mem_linux.go:

func sysUnused(v unsafe.Pointer, n uintptr) {

// By default, Linux's "transparent huge page" support will

// merge pages into a huge page if there's even a single

// present regular page, undoing the effects of madvise(adviseUnused)

// below. On amd64, that means khugepaged can turn a single

// 4KB page to 2MB, bloating the process's RSS by as much as

// 512X. (See issue #8832 and Linux kernel bug

// https://bugzilla.kernel.org/show_bug.cgi?id=93111)

......

}

Solution:

     # echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled
     # echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag

Guess you like

Origin blog.csdn.net/zgb40302/article/details/111933579