Skip to content

Instantly share code, notes, and snippets.

@xigang
Created April 22, 2019 05:03
Show Gist options
  • Save xigang/9a3d6464563e3ca945e5d2c0f8aa25f4 to your computer and use it in GitHub Desktop.
Save xigang/9a3d6464563e3ca945e5d2c0f8aa25f4 to your computer and use it in GitHub Desktop.
Compress memory usage, no cache
package main
import (
"fmt"
"net/http"
"time"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
memoryTicker := time.NewTicker(time.Millisecond * 5)
leak := make(map[int][]byte)
i := 0
go func() {
for range memoryTicker.C {
leak[i] = make([]byte, 1024)
i++
}
}()
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(":8081", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment