summaryrefslogtreecommitdiffstats
path: root/pkg/gui/background.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/gui/background.go')
-rw-r--r--pkg/gui/background.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/gui/background.go b/pkg/gui/background.go
index db267c0dc..061502a43 100644
--- a/pkg/gui/background.go
+++ b/pkg/gui/background.go
@@ -1,6 +1,8 @@
package gui
import (
+ "fmt"
+ "runtime"
"strings"
"time"
@@ -46,6 +48,29 @@ func (self *BackgroundRoutineMgr) startBackgroundRoutines() {
refreshInterval)
}
}
+
+ if self.gui.Config.GetDebug() {
+ self.goEvery(time.Second*time.Duration(10), self.gui.stopChan, func() error {
+ formatBytes := func(b uint64) string {
+ const unit = 1000
+ if b < unit {
+ return fmt.Sprintf("%d B", b)
+ }
+ div, exp := uint64(unit), 0
+ for n := b / unit; n >= unit; n /= unit {
+ div *= unit
+ exp++
+ }
+ return fmt.Sprintf("%.1f %cB",
+ float64(b)/float64(div), "kMGTPE"[exp])
+ }
+
+ m := runtime.MemStats{}
+ runtime.ReadMemStats(&m)
+ self.gui.c.Log.Infof("Heap memory in use: %s", formatBytes(m.HeapAlloc))
+ return nil
+ })
+ }
}
func (self *BackgroundRoutineMgr) startBackgroundFetch() {