github.com/fiatjaf/generic-ristretto@v0.0.1/contrib/memtest/withjemalloc.go (about) 1 //go:build jemalloc 2 // +build jemalloc 3 4 package main 5 6 import ( 7 "github.com/fiatjaf/generic-ristretto/z" 8 "github.com/golang/glog" 9 ) 10 11 func Calloc(size int) []byte { return z.Calloc(size, "memtest") } 12 func Free(bs []byte) { z.Free(bs) } 13 func NumAllocBytes() int64 { return z.NumAllocBytes() } 14 15 func check() { 16 if buf := z.CallocNoRef(1, "memtest"); len(buf) == 0 { 17 glog.Fatalf("Not using manual memory management. Compile with jemalloc.") 18 } else { 19 z.Free(buf) 20 } 21 22 z.StatsPrint() 23 } 24 25 func init() { 26 glog.Infof("USING JEMALLOC") 27 }