使用 go 1.1.1 编译在 linux i386 上。Cpu 利用率 %100. 老是崩溃 out of memory。
fatal error: runtime: out of memory
goroutine 1 [running]:
[fp=0xf7abdd34] runtime.throw(0x8277cf7)
/usr/local/go/src/pkg/runtime/panic.c:473 +0x66
[fp=0xf7abdd54] runtime.SysMap(0x28300000, 0xe0020000)
/usr/local/go/src/pkg/runtime/mem_linux.c:131 +0x7c
[fp=0xf7abdd64] runtime.MHeap_MapBits(0xf7b1d000)
/usr/local/go/src/pkg/runtime/mgc0.c:2413 +0x84
[fp=0xf7abdd84] runtime.MHeap_SysAlloc(0xf7b1d000, 0x100000)
/usr/local/go/src/pkg/runtime/zmalloc_linux_386.c:362 +0x11d
[fp=0xf7abddac] MHeap_Grow(0xf7b1d000, 0x10)
/usr/local/go/src/pkg/runtime/mheap.c:224 +0x50
[fp=0xf7abddcc] MHeap_AllocLocked(0xf7b1d000, 0x1, 0x8)
/usr/local/go/src/pkg/runtime/mheap.c:108 +0x287
[fp=0xf7abdde0] runtime.MHeap_Alloc(0xf7b1d000, 0x1, 0x8, 0x0, 0x1, ...)
/usr/local/go/src/pkg/runtime/mheap.c:77 +0x5d
[fp=0xf7abde18] MCentral_Grow(0xf7f21280)
/usr/local/go/src/pkg/runtime/mcentral.c:203 +0x82
[fp=0xf7abde3c] runtime.MCentral_AllocList(0xf7f21280, 0x20, 0xf7abde50)
/usr/local/go/src/pkg/runtime/mcentral.c:47 +0x4d
[fp=0xf7abde5c] runtime.MCache_Alloc(0xf7afd000, 0x8, 0x70, 0x1)
/usr/local/go/src/pkg/runtime/mcache.c:24 +0x73
[fp=0xf7abde8c] runtime.mallocgc(0x70, 0x1, 0x1, 0x1)
/usr/local/go/src/pkg/runtime/zmalloc_linux_386.c:47 +0xe1
[fp=0xf7abdea4] runtime.new()
/usr/local/go/src/pkg/runtime/zmalloc_linux_386.c:628 +0x53
[fp=0xf7abdec4] syscall.Accept(0x3, 0x16, 0x0, 0x0, 0x0, ...)
/usr/local/go/src/pkg/syscall/syscall_linux.go:428 +0x49
[fp=0xf7abdef8] net.accept(0x3, 0x0, 0x0, 0x0, 0x1, ...)
/usr/local/go/src/pkg/net/sock_cloexec.go:57 +0xb5
[fp=0xf7abdf38] net.(*netFD).accept(0x18362780, 0x81c5070, 0x0, 0x0, 0x0, ...)
/usr/local/go/src/pkg/net/fd_unix.go:382 +0x17e
[fp=0xf7abdf50] net.(*TCPListener).AcceptTCP(0x18300508, 0x0, 0x186805e0, 0x981fe9c0)
/usr/local/go/src/pkg/net/tcpsock_posix.go:229 +0x42
[fp=0xf7abdf68] net.(*TCPListener).Accept(0x18300508, 0x1, 0x1, 0x8154480, 0x981fc420, ...)
/usr/local/go/src/pkg/net/tcpsock_posix.go:239 +0x29
[fp=0xf7abdfc4] main.main()
@polaris
但是这个时候,程序运行开始的实际内存就到 6000byte。后来把 con 放到 handle 里面处理,抛弃 defer 的方法。 开始的实际内存降了 2000 byte。
#4
更多评论