Go garbage collector hung due to preemptive scheduling failure
go build the following code and use the command ‘GODEBUG=gctrace=2 GOGC=5 ./main’ to run.
package main
import (
"fmt"
"time"
)
const (
Num = 1 << 20
)
func main() {
go func() {
for {
select {
case <-time.After(time.Second):
fmt.Printf("hello world\n")
}
}
}()
vs := make([]int64, Num)
for i := 0; i < 100; i++ {
for i := 0; i < len(vs); i++ {
vs = append(vs[:i], vs[i+1:]...)
i--
}
vs = vs[:Num]
}
}
For a purely computational loop, how to set a more reasonable value in the design of the program? 8192 is a reasonable value?