-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: VSZ(virtual memory size) Increased by Approx. 500MB: GO Apps Upgraded from go1.19.3 to go1.22.0 #66796
Comments
given it's just virtual memory, why is this an issue? |
Higher virtual memory consumption can signify various issues. With limited physical memory on my system, excessive virtual memory usage could result in resource contention, possibly indicating memory leaks or inefficient memory management. Each Go application is utilizing 122% of virtual memory(see %VSZ), potentially impacting other processes and leading to decreased system performance or responsiveness. My concern lies with the significant 500MB increase in virtual memory usage observed in Go releases post 1.19.3. What factors are contributing to this surge in virtual memory consumption? |
I'm not quite sure what you mean by "resource contention" or "inefficient memory management". An application that maps a single block of virtual addresses (even one much larger than physical memory) doesn't use more than a constant amount of additional RAM: the only resources being used in this case are an extra entry in the kernel's page table and one in the processor's TLB. And unbacked virtual address mappings may be used to implement algorithms that save actual RAM.
Are you using busybox top? It differs from the standard one: its %VSZ is the ratio of virtual address space to MemTotal (physical memory, used + free) (code), so it is quite normal for it to be more than 100%, or even much higher. |
Can anyone help me by answering this. "My concern lies with the significant 500MB increase in virtual memory usage observed in Go releases post 1.19.3. What factors are contributing to this surge in virtual memory consumption?" |
I don't know, but you could try running your application in a debugger such as lldb or dlv, with a breakpoint on the mmap system call, conditional on a size (reg. SI or R1) larger than some big value, and see what the Go stack looks like at that point. |
Go's virtual address mapping changes over time. It may map or reserve memory address space differently, but the actually used memory space should not increase much.
Could you explain what impact actually occurred? Thanks. |
See also https://go.dev/doc/gc-guide#A_note_about_virtual_memory, which echoes what others have said here already. Given the versions involved, it's possibly also related to changes to how huge pages are managed in Go 1.21, but that should not have affected virtual memory footprint. See https://go.dev/doc/gc-guide#Linux_transparent_huge_pages anyway, in case it offers you some insights. |
I am getting occasional crash when doing stress testing of my application. And this crashes I am seeing only after Go version upgrade to 1.22.0 And each crash is producing CORE file which is giving similar stack trace While doing this analysis I observed about this 500MB increase of virtual space in Go application, hence asked a question here to know what has changed in recent GO version so that it is showing consumed VSZ increased by 500MB.
Yes, I agree to this as actual memory consumption of my application didn't increase even with increased VSZ. With all the explanation given before, can I safely assume this VSZ increased with new Go version 1.22.0 has no impact on Go applications as it is only related to Virtual memory? |
Could you open a new issue for that crash?
Yes. I'm going to close this issue, as I think the virtual memory part at least is resolved. |
Go version
go version go1.22.0 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I upgraded all my Go application in my platform from go1.19.3 to go1.22.0. I have total 3 application written in GO in my platform.
What did you see happen?
After the upgrade, I observed an approximate increase of 500MB in the VSZ (Virtual Memory Size) as displayed in the 'top' command (a Linux command) for all my Go applications. Below are the VSZ values captured from the 'top' command for each application running on go1.22.0 (after the upgrade):
The VSZ is reported to be approximately 1200MB for each of my Go applications individually.
What did you expect to see?
Before the Go upgrade, I was using go1.19.3 to build my applications, and here's what I used to observe.
The VSZ (virtual memory size) was reported to be approximately 700MB for each of my Go applications individually.
Please note:
If I rebuild any one of these three applications using go1.19.3 and run it, I observe that the VSZ (virtual memory size) of that particular application returns to the normal reading of 700MB. However, the other two applications continue to run with a VSZ of 1200MB.
I attempted to build my applications with Go version go1.22.2 as well, but the issue persists.
The text was updated successfully, but these errors were encountered: