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