func MemProfile(p []MemProfileRecord, inuseZero bool) (n int, ok bool) {
	lock(&proflock)
	clear := true
	for b := mbuckets; b != nil; b = b.allnext {
		mp := b.mp()
		if inuseZero || mp.alloc_bytes != mp.free_bytes {
			n++
		}
		if mp.allocs != 0 || mp.frees != 0 {
			clear = false
		}
	}
	if clear {
		// Absolutely no data, suggesting that a garbage collection
		// has not yet happened. In order to allow profiling when
		// garbage collection is disabled from the beginning of execution,
		// accumulate stats as if a GC just happened, and recount buckets.
		mprof_GC()
		mprof_GC()
		n = 0
		for b := mbuckets; b != nil; b = b.allnext {
			mp := b.mp()
			if inuseZero || mp.alloc_bytes != mp.free_bytes {
				n++
			}
		}
	}
	if n <= len(p) {
		ok = true
		idx := 0
		for b := mbuckets; b != nil; b = b.allnext {
			mp := b.mp()
			if inuseZero || mp.alloc_bytes != mp.free_bytes {
				record(&p[idx], b)
				idx++
			}
		}
	}
	unlock(&proflock)
	return
}
// MemProfile returns a profile of memory allocated and freed per allocation
// site.
//
// MemProfile returns n, the number of records in the current memory profile.
// If len(p) >= n, MemProfile copies the profile into p and returns n, true.
// If len(p) < n, MemProfile does not change p and returns n, false.
//
// If inuseZero is true, the profile includes allocation records
// where r.AllocBytes > 0 but r.AllocBytes == r.FreeBytes.
// These are sites where memory was allocated, but it has all
// been released back to the runtime.
//
// The returned profile may be up to two garbage collection cycles old.
// This is to avoid skewing the profile toward allocations; because
// allocations happen in real time but frees are delayed until the garbage
// collector performs sweeping, the profile only accounts for allocations
// that have had a chance to be freed by the garbage collector.
//
// Most clients should use the runtime/pprof package or
// the testing package's -test.memprofile flag instead
// of calling MemProfile directly.
MemProfile returns a profile of memory allocated and freed per allocation
site.

MemProfile returns n, the number of records in the current memory profile.
If len(p) >= n, MemProfile copies the profile into p and returns n, true.
If len(p) < n, MemProfile does not change p and returns n, false.

If inuseZero is true, the profile includes allocation records
where r.AllocBytes > 0 but r.AllocBytes == r.FreeBytes.
These are sites where memory was allocated, but it has all
been released back to the runtime.

The returned profile may be up to two garbage collection cycles old.
This is to avoid skewing the profile toward allocations; because
allocations happen in real time but frees are delayed until the garbage
collector performs sweeping, the profile only accounts for allocations
that have had a chance to be freed by the garbage collector.

Most clients should use the runtime/pprof package or
the testing package's -test.memprofile flag instead
of calling MemProfile directly.
// MemProfile returns a profile of memory allocated and freed per allocation // site . // // MemProfile returns n the number of records in the current memory profile . // If len ( p ) > = n MemProfile copies the profile into p and returns n true . // If len ( p ) < n MemProfile does not change p and returns n false . // // If inuseZero is true the profile includes allocation records // where r . AllocBytes > 0 but r . AllocBytes == r . FreeBytes . // These are sites where memory was allocated but it has all // been released back to the runtime . // // The returned profile may be up to two garbage collection cycles old . // This is to avoid skewing the profile toward allocations ; because // allocations happen in real time but frees are delayed until the garbage // collector performs sweeping the profile only accounts for allocations // that have had a chance to be freed by the garbage collector . // // Most clients should use the runtime / pprof package or // the testing package ' s - test . memprofile flag instead // of calling MemProfile directly .
func MemProfile(p []MemProfileRecord, inuseZero bool) (n int, ok bool) {
	lock(&proflock)
	clear := true
	for b := mbuckets; b != nil; b = b.allnext {
		mp := b.mp()
		if inuseZero || mp.alloc_bytes != mp.free_bytes {
			n++
		}
		if mp.allocs != 0 || mp.frees != 0 {
			clear = false
		}
	}
	if clear {
		mprof_GC()
		mprof_GC()
		n = 0
		for b := mbuckets; b != nil; b = b.allnext {
			mp := b.mp()
			if inuseZero || mp.alloc_bytes != mp.free_bytes {
				n++
			}
		}
	}
	if n <= len(p) {
		ok = true
		idx := 0
		for b := mbuckets; b != nil; b = b.allnext {
			mp := b.mp()
			if inuseZero || mp.alloc_bytes != mp.free_bytes {
				record(&p[idx], b)
				idx++
			}
		}
	}
	unlock(&proflock)
	return
}
func MemProfile ( p [ ] MemProfileRecord , inuseZero bool ) ( n int , ok bool ) { lock ( & proflock ) clear := true for b := mbuckets ; b != nil ; b = b . allnext { mp := b . mp ( ) if inuseZero || mp . alloc_bytes != mp . free_bytes { n ++ } if mp . allocs != 0 || mp . frees != 0 { clear = false } } if clear { mprof_GC ( ) mprof_GC ( ) n = 0 for b := mbuckets ; b != nil ; b = b . allnext { mp := b . mp ( ) if inuseZero || mp . alloc_bytes != mp . free_bytes { n ++ } } } if n <= len ( p ) { ok = true idx := 0 for b := mbuckets ; b != nil ; b = b . allnext { mp := b . mp ( ) if inuseZero || mp . alloc_bytes != mp . free_bytes { record ( & p [ idx ] , b ) idx ++ } } } unlock ( & proflock ) return }
MemProfile returns a profile of memory allocated and freed per allocation
site.
MemProfile returns a profile of memory allocated and freed per allocation site .
// Absolutely no data, suggesting that a garbage collection // has not yet happened. In order to allow profiling when // garbage collection is disabled from the beginning of execution, // accumulate stats as if a GC just happened, and recount buckets.