github.com/songzhibin97/gkit@v1.2.13/watching/example/alloc/alloc.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  	"time"
     7  
     8  	"github.com/songzhibin97/gkit/watching"
     9  )
    10  
    11  func init() {
    12  	http.HandleFunc("/alloc", alloc)
    13  	go http.ListenAndServe(":10003", nil)
    14  }
    15  
    16  func main() {
    17  	w := watching.NewWatching(
    18  		watching.WithCollectInterval("2s"),
    19  		watching.WithCoolDown("1m"),
    20  		watching.WithDumpPath("./tmp"),
    21  		watching.WithTextDump(),
    22  		watching.WithMemDump(3, 25, 80),
    23  	)
    24  	w.EnableMemDump().Start()
    25  	time.Sleep(time.Hour)
    26  }
    27  
    28  func alloc(wr http.ResponseWriter, req *http.Request) {
    29  	m := make(map[string]string, 102400)
    30  	for i := 0; i < 1000; i++ {
    31  		m[fmt.Sprint(i)] = fmt.Sprint(i)
    32  	}
    33  	_ = m
    34  }