Skip to content

runtime/trace: NextGC is 0 if no GC was triggered during the trace #52517

@WangLeonard

Description

@WangLeonard

What version of Go are you using (go version)?

$ go version
go version devel go1.19-7d48c32412 Wed Apr 13 21:11:38 2022 +0800 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

package main

import (
	"os"
	"runtime"
	"runtime/trace"
)

var global interface{}

func init() {
	global = make([]interface{}, 100000000)
}

var global2 []interface{}

func main() {
	runtime.GC()
	var f, _ = os.Create("trace1.out")
	trace.Start(f)
	for i := 0; i < 10000; i++ {
		global2 = append(global2, make([]int, 100))
	}
	trace.Stop()

	global2 = nil

	var f2, _ = os.Create("trace2.out")
	trace.Start(f2)
	runtime.GC()
	for i := 0; i < 10000; i++ {
		global2 = append(global2, make([]int, 100))
	}
	trace.Stop()
	global2 = nil
}


// go tool trace -http=127.0.0.1:8082 ./trace1.out
// go tool trace -http=127.0.0.1:8083 ./trace2.out

What did you expect to see?

image

image

What did you see instead?

image

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions