github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/server/status/jemalloc_test.go (about) 1 // Copyright 2017 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 // +build !stdmalloc 12 13 package status 14 15 import ( 16 "context" 17 "testing" 18 19 "github.com/cockroachdb/cockroach/pkg/util/leaktest" 20 ) 21 22 func TestJemalloc(t *testing.T) { 23 defer leaktest.AfterTest(t)() 24 25 ctx := context.Background() 26 cgoAllocated, _, err := getJemallocStats(ctx) 27 if err != nil { 28 t.Fatal(err) 29 } 30 for i := 0; i < 10; i++ { 31 allocateMemory() 32 cgoAllocatedN, _, err := getJemallocStats(ctx) 33 if err != nil { 34 t.Fatal(err) 35 } 36 if cgoAllocatedN == cgoAllocated { 37 t.Errorf("allocated stat not incremented on allocation: %d", cgoAllocated) 38 } 39 cgoAllocated = cgoAllocatedN 40 } 41 }