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

     1  package main
     2  
     3  import (
     4  	"net/http"
     5  	"time"
     6  
     7  	"github.com/songzhibin97/gkit/watching"
     8  )
     9  
    10  func init() {
    11  	http.HandleFunc("/make1gb", make1gbslice)
    12  	go http.ListenAndServe(":10003", nil)
    13  }
    14  
    15  func main() {
    16  	w := watching.NewWatching(
    17  		watching.WithCollectInterval("2s"),
    18  		watching.WithCoolDown("1m"),
    19  		// watching.WithDumpPath("./tmp"),
    20  		watching.WithTextDump(),
    21  		watching.WithMemDump(1, 5, 10),
    22  	)
    23  	w.EnableMemDump().Start()
    24  	time.Sleep(time.Hour)
    25  }
    26  
    27  func make1gbslice(wr http.ResponseWriter, req *http.Request) {
    28  	a := make([]byte, 1073741824)
    29  	_ = a
    30  }