On my machine, there is a significant difference; MemStats.Sys is short by 32 MB or so and shows very little allocation outside of HeapSys. If you look at the Linux kernel memory map (with eg pmap) or use strace -e trace=%memory on the program, it is clearly false, because there is a large 32 MB allocation that is not reflected in MemStats. This allocation is the L2 arena map, allocated in *mheap.syAlloc (currently here). Because this allocation is made by calling persistentalloc() with the last parameter being nil, it is not accounted for in any memstats value, and on modest Go programs it may amount to a significant amount of their runtime OS level memory usage.
(If this is deliberate I believe it's not the right approach, but I suspect it may be an oversight and the CL for the commit doesn't contain any discussion of it either way that I could see. The related heapArena structure is accounted for, for example.)
The text was updated successfully, but these errors were encountered: