Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gc variables in use #39

Closed
pkujhd opened this issue Jul 30, 2021 · 1 comment
Closed

gc variables in use #39

pkujhd opened this issue Jul 30, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@pkujhd
Copy link
Owner

pkujhd commented Jul 30, 2021

package main

import (
	"fmt"
	"runtime"
)

type Vertex struct {
	X, Y int
}

func (v *Vertex) Print() {
	fmt.Println("print", v)
}

type PrintInf interface {
	Print()
}

var uptr *Vertex
var uptra *Vertex

func main() {
	uptr = new(Vertex)
	uptra = uptr
	uptr.X = 1000
	uptr.Y = 1000
	uptr = new(Vertex)
	fmt.Println(uptr, uptra)
	runtime.GC()
	fmt.Println(uptr.X, uptr.Y, uptra)
}

run result:

&{0 0} &{1000 1000}
0 0 &{1000 1000}
&{0 0} &{1000 1000}
0 0 &{1000 2109488}
&{0 0} &{1000 1000}
0 0 &{0 0}
&{0 0} &{1000 1000}
0 0 &{1000 2109488}
&{0 0} &{1000 1000}
0 0 &{0 0}
&{0 0} &{1000 1000}
0 0 &{1000 2109488}
&{0 0} &{1000 1000}
0 0 &{0 0}
&{0 0} &{1000 1000}
0 0 &{0 0}
&{0 0} &{1000 1000}
0 0 &{0 0}
&{0 0} &{1000 1000}
0 0 &{0 0}

runtime gc variables in use

@pkujhd pkujhd added the bug Something isn't working label Jul 30, 2021
@pkujhd
Copy link
Owner Author

pkujhd commented Jul 30, 2021

not set gcdatamask and gcbssmask will lead to gcmarkroot failed.

@pkujhd pkujhd closed this as completed in d41c48c Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant