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

@chgitcrazy chgitcrazy commented Jun 19, 2019

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

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 19, 2019

@mknyszek

This comment has been minimized.

Copy link
Contributor

@mknyszek mknyszek commented Jun 19, 2019

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

This comment has been minimized.

Copy link
Author

@chgitcrazy chgitcrazy commented Jun 21, 2019

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.

@chgitcrazy chgitcrazy closed this Jun 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.