golang 创建超过10万个Go程时报错stackcacherefill
wkh · · 4235 次点击 · · 开始浏览package main
import(
//"fmt"
"time"
)
var c = make(chan int,100)
func gofunc(){
time.Sleep(0)
c<-0
}
func main(){
for i:=0;i<10;i++{
for j:=0;j<10000;j++{
go gofunc()
}
time.Sleep(time.Second)
}
}
fatal error: out of memory (stackcacherefill)
runtime stack:
runtime.throw(0x45f820)
c:/go/src/pkg/runtime/panic.c:520 +0x71
stackcacherefill()
c:/go/src/pkg/runtime/stack.c:52 +0x87
runtime.stackalloc(0x12219360, 0x4000)
c:/go/src/pkg/runtime/stack.c:124 +0x154
mstackalloc(0x11514000)
c:/go/src/pkg/runtime/proc.c:1754 +0x43
runtime.mcall(0x423794)
c:/go/src/pkg/runtime/asm_386.s:190 +0x40
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
package main
import(
//"fmt"
"time"
)
var c = make(chan int,100)
func gofunc(){
time.Sleep(0)
c<-0
}
func main(){
for i:=0;i<10;i++{
for j:=0;j<10000;j++{
go gofunc()
}
time.Sleep(time.Second)
}
}
fatal error: out of memory (stackcacherefill)
runtime stack:
runtime.throw(0x45f820)
c:/go/src/pkg/runtime/panic.c:520 +0x71
stackcacherefill()
c:/go/src/pkg/runtime/stack.c:52 +0x87
runtime.stackalloc(0x12219360, 0x4000)
c:/go/src/pkg/runtime/stack.c:124 +0x154
mstackalloc(0x11514000)
c:/go/src/pkg/runtime/proc.c:1754 +0x43
runtime.mcall(0x423794)
c:/go/src/pkg/runtime/asm_386.s:190 +0x40