I ran a goroutine 3 times, at the end of each, I run runtime.GC() and print mem stats. Just before exiting program, I do it once more. This is what I get in each runs -
HeapSys = 720896 Alloc = 48408 TotalAlloc = 62464 StackSys = 327680 Sys = 2461696 GCSys = 63488 NumGC = 1 PauseTotalNs = 1680857
HeapSys = 720896 Alloc = 48408 TotalAlloc = 63496 StackSys = 327680 Sys = 2461696 GCSys = 63488 NumGC = 2 PauseTotalNs = 1905615
HeapSys = 753664 Alloc = 48408 TotalAlloc = 64528 StackSys = 294912 Sys = 2461696 GCSys = 63488 NumGC = 3 PauseTotalNs = 2123106
HeapSys = 786432 Alloc = 48280 TotalAlloc = 65560 StackSys = 262144 Sys = 2461696 GCSys = 63488 NumGC = 4 PauseTotalNs = 2341283
While I understand most of the allocations in my program, I don't get why HeapSys is more than 15 times of Alloc. If this is reserved virtual space from OS, why does it have to be this big? Any reasons.