Why does GOMEMLIMIT take up significant physical memory for unused virtual memory?

While debugging memory bloat in a Go application recently, I found that removing the GOMEMLIMIT soft memory limit and disabling transparent huge pages partially mitigated the issue. However, I couldn't fully explain why these changes worked. So I thought why not ask the internet about it. A simplified memory bloat program The following Go program vm-demo.go demonstrates memory bloat by allocating…