summaryrefslogtreecommitdiff
path: root/vendor/modernc.org/libc/mem.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/modernc.org/libc/mem.go')
-rw-r--r--vendor/modernc.org/libc/mem.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/vendor/modernc.org/libc/mem.go b/vendor/modernc.org/libc/mem.go
index cf4644edc..df852c2d6 100644
--- a/vendor/modernc.org/libc/mem.go
+++ b/vendor/modernc.org/libc/mem.go
@@ -121,6 +121,25 @@ func UsableSize(p uintptr) types.Size_t {
return types.Size_t(memory.UintptrUsableSize(p))
}
+type MemAllocatorStat struct {
+ Allocs int
+ Bytes int
+ Mmaps int
+}
+
+// MemStat returns the global memory allocator statistics.
+// should be compiled with the memory.counters build tag for the data to be available.
+func MemStat() MemAllocatorStat {
+ allocMu.Lock()
+ defer allocMu.Unlock()
+
+ return MemAllocatorStat{
+ Allocs: allocator.Allocs,
+ Bytes: allocator.Bytes,
+ Mmaps: allocator.Mmaps,
+ }
+}
+
// MemAuditStart locks the memory allocator, initializes and enables memory
// auditing. Finaly it unlocks the memory allocator.
//