github.com/outcaste-io/ristretto@v0.2.3/z/calloc.go (about) 1 package z 2 3 import "sync/atomic" 4 5 var numBytes int64 6 7 // NumAllocBytes returns the number of bytes allocated using calls to z.Calloc. The allocations 8 // could be happening via either Go or jemalloc, depending upon the build flags. 9 func NumAllocBytes() int64 { 10 return atomic.LoadInt64(&numBytes) 11 } 12 13 // MemStats is used to fetch JE Malloc Stats. The stats are fetched from 14 // the mallctl namespace http://jemalloc.net/jemalloc.3.html#mallctl_namespace. 15 type MemStats struct { 16 // Total number of bytes allocated by the application. 17 // http://jemalloc.net/jemalloc.3.html#stats.allocated 18 Allocated uint64 19 // Total number of bytes in active pages allocated by the application. This 20 // is a multiple of the page size, and greater than or equal to 21 // Allocated. 22 // http://jemalloc.net/jemalloc.3.html#stats.active 23 Active uint64 24 // Maximum number of bytes in physically resident data pages mapped by the 25 // allocator, comprising all pages dedicated to allocator metadata, pages 26 // backing active allocations, and unused dirty pages. This is a maximum 27 // rather than precise because pages may not actually be physically 28 // resident if they correspond to demand-zeroed virtual memory that has not 29 // yet been touched. This is a multiple of the page size, and is larger 30 // than stats.active. 31 // http://jemalloc.net/jemalloc.3.html#stats.resident 32 Resident uint64 33 // Total number of bytes in virtual memory mappings that were retained 34 // rather than being returned to the operating system via e.g. munmap(2) or 35 // similar. Retained virtual memory is typically untouched, decommitted, or 36 // purged, so it has no strongly associated physical memory (see extent 37 // hooks http://jemalloc.net/jemalloc.3.html#arena.i.extent_hooks for 38 // details). Retained memory is excluded from mapped memory statistics, 39 // e.g. stats.mapped (http://jemalloc.net/jemalloc.3.html#stats.mapped). 40 // http://jemalloc.net/jemalloc.3.html#stats.retained 41 Retained uint64 42 }