mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: fix memory profiler
There are 3 issues: 1. Skip argument of callers is off by 3, so that all allocations are deep inside of memory profiler. 2. Memory profiling statistics are not updated after runtime.GC. 3. Testing package does not update memory profiling statistics before capturing the profile. Also add an end-to-end test. Fixes #8867. LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/148710043
This commit is contained in:
parent
1552e62d70
commit
8f47c837fd
4 changed files with 150 additions and 2 deletions
|
|
@ -620,6 +620,7 @@ func after() {
|
|||
fmt.Fprintf(os.Stderr, "testing: %s\n", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
runtime.GC() // materialize all statistics
|
||||
if err = pprof.WriteHeapProfile(f); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "testing: can't write %s: %s\n", *memProfile, err)
|
||||
os.Exit(2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue