github.com/outcaste-io/ristretto@v0.2.3/contrib/memtest/withjemalloc.go (about)

     1  //+build jemalloc
     2  
     3  package main
     4  
     5  import (
     6  	"os"
     7  
     8  	"github.com/outcaste-io/ristretto/z"
     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  		panic("Not using manual memory management. Compile with jemalloc.")
    18  		os.Exit(1)
    19  	} else {
    20  		z.Free(buf)
    21  	}
    22  
    23  	z.StatsPrint()
    24  }