Print heap allocation before profiling memory
@@ -26,6 +26,11 @@ import (
"github.com/googlecloudplatform/gcsfuse/internal/logger"
)
+const (
+ KiB = 1024
+ MiB = 1024 * KiB
+)
+
func HandleMemoryProfileSignals() {
profileOnce := func(path string) (err error) {
@@ -63,6 +68,10 @@ func HandleMemoryProfileSignals() {
for range c {
path := fmt.Sprintf("/tmp/mem-%d.pprof", time.Now().UnixNano())
+ var m runtime.MemStats
+ runtime.ReadMemStats(&m)
+ logger.Infof("Heap allocation: %d MiB", m.Alloc / MiB)
+
err := profileOnce(path)
if err == nil {
logger.Infof("Wrote memory profile to %s.", path)
