github.com/songzhibin97/gkit@v1.2.13/gctuner/mem_test.go (about)

     1  package gctuner
     2  
     3  import (
     4  	"runtime"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestMem(t *testing.T) {
    11  	defer runtime.GC() // make it will not affect other tests
    12  
    13  	is := assert.New(t)
    14  	const mb = 1024 * 1024
    15  
    16  	heap := make([]byte, 100*mb+1)
    17  	inuse := readMemoryInuse()
    18  	t.Logf("mem inuse: %d MB", inuse/mb)
    19  	is.GreaterOrEqual(inuse, uint64(100*mb))
    20  	heap[0] = 0
    21  }