Skip to content
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: struct MemStats in go 1.9.3 and go 1.11.5 #32678

Closed
chgitcrazy opened this issue Jun 19, 2019 · 3 comments
Closed

runtime: struct MemStats in go 1.9.3 and go 1.11.5 #32678

chgitcrazy opened this issue Jun 19, 2019 · 3 comments

Comments

@chgitcrazy
Copy link

When I use go 1.9.3 , I call the Sys field of the Struct MemStats from package 'runtime' , the result is about 10M , But when I upgrade to go 1.11.5, I call the same api , the result is about 70M. By reading the api source , I couldn't find any difference ,hope for explanation .

@ianlancetaylor ianlancetaylor changed the title struct MemStats in go 1.9.3 and go 1.11.5 runtime: struct MemStats in go 1.9.3 and go 1.11.5 Jun 19, 2019
@ianlancetaylor
Copy link
Contributor

CC @aclements @mknyszek

@mknyszek
Copy link
Contributor

Sys represents the total amount of virtual memory used. I don't know all the details of what changed between go 1.9.3 and go 1.11.5, but if Sys goes up it should generally be regarded as a non-issue, since it doesn't generally reflect the memory actually counted against your process by the operating system. That is, Sys is not a measure of how much physical memory your application is using, just how much memory has been "mapped" or reserved. For example, today (Go 1.12, 1.13, and I believe true for Go 1.11 as well), we always map in 64 MiB of memory for use on many platforms (e.g. linux/amd64). That's likely where most of the reported 70 MB is coming from.

@chgitcrazy
Copy link
Author

Sys represents the total amount of virtual memory used. I don't know all the details of what changed between go 1.9.3 and go 1.11.5, but if Sys goes up it should generally be regarded as a non-issue, since it doesn't generally reflect the memory actually counted against your process by the operating system. That is, Sys is not a measure of how much physical memory your application is using, just how much memory has been "mapped" or reserved. For example, today (Go 1.12, 1.13, and I believe true for Go 1.11 as well), we always map in 64 MiB of memory for use on many platforms (e.g. linux/amd64). That's likely where most of the reported 70 MB is coming from.

Thank you. I will look for new method to calculate the physical memory.

@golang golang locked and limited conversation to collaborators Jun 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants