github.com/etecs-ru/ristretto@v0.9.1/contrib/memtest/withjemalloc.go (about)

     1  //go:build jemalloc
     2  
     3  package main
     4  
     5  import (
     6  	"log"
     7  
     8  	"github.com/etecs-ru/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  		log.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  	log.Println("USING JEMALLOC")
    27  }