如何准确跟踪内存使用情况?

I am trying to build a small tool that will allow me to run a program and track memory usage through Go. I am using r.exec = exec.Command(r.Command, r.CommandArgs...) to run the command, and runtime.MemStats to track memory usage (in a separate go routine):

func monitorRuntime() {
    m := &runtime.MemStats{}
    f, err := os.Create(fmt.Sprintf("mmem_%s.csv", getFileTimeStamp()))
    if err != nil {
        panic(err)
    }
    f.WriteString("Time;Allocated;Total Allocated; System Memory;Num Gc;Heap Allocated;Heap System;Heap Objects;Heap Released;
")
    for {
        runtime.ReadMemStats(m)
        f.WriteString(fmt.Sprintf("%s;%d;%d;%d;%d;%d;%d;%d;%d;
", getTimeStamp(), m.Alloc, m.TotalAlloc, m.Sys, m.NumGC, m.HeapAlloc, m.HeapSys, m.HeapObjects, m.HeapReleased))
        time.Sleep(5 * time.Second)
    }
}

When I tested my code with simple program that just sits there (for about 12 hours), I noticed that Go constantly allocating more memory: System Memory Heap Allocation

I did a few more tests such as running the monitorRuntime() function without any other code, or using pprof, such as:

package main

import (
    "net/http"
    _ "net/http/pprof"
)

func main() {
    http.ListenAndServe(":8080", nil)
}

Yet I still noticed that memory allocation keep going up just like in the graphs.

How can I accurately track memory usage of the program I want to run through go? I know one way, which I used in the past, is to use /proc/$PID/statm but that file doesn't exist in every operation system (such as Mac OS, or Windows)

On Linux (RedHat) the following will show memory usage: ps -No pid,comm,size,vsize,args:90