Go踩过的坑之内存分配 fatal error: out of
2021-03-17 本文已影响0人
五岁小孩
Go踩过的坑之make slice panic: runtime error: makeslice: len out of range
重现
func main(){
var peek []byte
//var len=1000*1000*1000 //success
//var len=1000*1000*1000*1000// fatal error: out of memory allocating heap arena metadata
var len=1000*1000*1000*1000*1000 //panic: runtime error: makeslice: len out of range
//var len=-8//panic: runtime error: makeslice: len out of range
peek = append(peek, make([]byte, len)...)
fmt.Println("end......")
}