]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: note interactions between GC and MemProfile
authorShenghou Ma <minux@golang.org>
Thu, 12 Nov 2015 22:33:15 +0000 (17:33 -0500)
committerMinux Ma <minux@golang.org>
Thu, 3 Dec 2015 02:11:52 +0000 (02:11 +0000)
Change-Id: Icce28fc4937cc73c0712c054161222f034381c2f
Reviewed-on: https://go-review.googlesource.com/16876
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/mprof.go

index ff4b9e910383a9f9b9a49f157f29bea962d3ac04..684ab0b0551eef8ff7f92b599e971deb3622c6b0 100644 (file)
@@ -368,6 +368,9 @@ func (r *MemProfileRecord) Stack() []uintptr {
        return r.Stack0[0:]
 }
 
+// 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.
@@ -377,6 +380,12 @@ func (r *MemProfileRecord) Stack() []uintptr {
 // 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.