fatal error: runtime: out of memory
goroutine 1 [running]:
runtime.throw(0x71e777)
/usr/local/go/src/pkg/runtime/panic.c:464 +0x69 fp=0x7f2c829f5768
runtime.SysMap(0xc216100000, 0x8000000, 0x72c538)
/usr/local/go/src/pkg/runtime/mem_linux.c:131 +0xfe fp=0x7f2c829f5798
runtime.MHeap_SysAlloc(0x736480, 0x8000000)
/usr/local/go/src/pkg/runtime/malloc.goc:473 +0x10a fp=0x7f2c829f57d8
MHeap_Grow(0x736480, 0x8000)
/usr/local/go/src/pkg/runtime/mheap.c:241 +0x5d fp=0x7f2c829f5818
MHeap_AllocLocked(0x736480, 0x8000, 0xc200000000)
/usr/local/go/src/pkg/runtime/mheap.c:126 +0x305 fp=0x7f2c829f5858
runtime.MHeap_Alloc(0x736480, 0x8000, 0x100000000, 0x1)
/usr/local/go/src/pkg/runtime/mheap.c:95 +0x7b fp=0x7f2c829f5880
runtime.mallocgc(0x8000000, 0x525e81, 0x1)
/usr/local/go/src/pkg/runtime/malloc.goc:89 +0x484 fp=0x7f2c829f58f0
cnew(0x525e80, 0x8000000, 0xc200000001)
/usr/local/go/src/pkg/runtime/malloc.goc:718 +0xc1 fp=0x7f2c829f5910
runtime.cnewarray(0x525e80, 0x8000000)
/usr/local/go/src/pkg/runtime/malloc.goc:731 +0x3a fp=0x7f2c829f5930
makeslice1(0x51daa0, 0x8000000, 0x8000000, 0x7f2c829f5990)
/usr/local/go/src/pkg/runtime/slice.c:57 +0x4d fp=0x7f2c829f5948
runtime.makeslice(0x51daa0, 0x8000000, 0x8000000, 0x0, 0x8000000, ...)
/usr/local/go/src/pkg/runtime/slice.c:38 +0x98 fp=0x7f2c829f5978
loveoneanother.at/tiedot/file.(*File).CheckSizeAndEnsure(0xc21001eeb0, 0x8000000)
/tmp/selfgz6496/src/loveoneanother.at/tiedot/file/file.go:87 +0x132 fp=0x7f2c829f5a00
loveoneanother.at/tiedot/file.Open(0xc210059980, 0x30, 0x8000000, 0xc21001eeb0, 0x0, ...)
/tmp/selfgz6496/src/loveoneanother.at/tiedot/file/file.go:36 +0x2dd fp=0x7f2c829f5aa8
loveoneanother.at/tiedot/file.OpenCol(0xc210059980, 0x30, 0x2, 0xc210059980, 0x30)
/tmp/selfgz6496/src/loveoneanother.at/tiedot/file/col.go:30 +0x3a fp=0x7f2c829f5b18
loveoneanother.at/tiedot/db.OpenCol(0xc210036ba0, 0x2b, 0xc21001ee60, 0x0, 0x0)
/tmp/selfgz6496/src/loveoneanother.at/tiedot/db/col.go:56 +0x30c fp=0x7f2c829f5bf8
loveoneanother.at/tiedot/db.OpenDB(0xc210036450, 0x21, 0xc21004c180, 0x0, 0x0)
/tmp/selfgz6496/src/loveoneanother.at/tiedot/db/db.go:30 +0x2bb fp=0x7f2c829f5d10
main.main()
/tmp/selfgz6496/databank.go:355 +0x149 fp=0x7f2c829f5f48
runtime.main()
/usr/local/go/src/pkg/runtime/proc.c:215 +0x11f fp=0x7f2c829f5fa0
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1389 fp=0x7f2c829f5fa8
goroutine 3 [syscall]:
os/signal.loop()
/usr/local/go/src/pkg/os/signal/signal_unix.go:21 +0x1e
created by os/signal.init·1
/usr/local/go/src/pkg/os/signal/signal_unix.go:27 +0x31
The problem function is CheckSizeAndEnsure(). Perhaps if the call to make
([]byte, file.Growth)
Was split up into smaller chunks and written separately? That shouldn't have a runtime performance hit.
I split the write call into 64 different interations to reduce the impact on memory. This solved the above problem, but a new one appeared after 5 collections have been opened:
fatal error: runtime: out of memory
goroutine 1 [running]:
runtime.throw(0x71e777)
/usr/local/go/src/pkg/runtime/panic.c:464 +0x69 fp=0x7fc88b846898
runtime.SysMap(0xc21a100000, 0x2000000, 0x72c538)
/usr/local/go/src/pkg/runtime/mem_linux.c:131 +0xfe fp=0x7fc88b8468c8
runtime.MHeap_SysAlloc(0x736480, 0x2000000)
/usr/local/go/src/pkg/runtime/malloc.goc:473 +0x10a fp=0x7fc88b846908
MHeap_Grow(0x736480, 0x2000)
/usr/local/go/src/pkg/runtime/mheap.c:241 +0x5d fp=0x7fc88b846948
MHeap_AllocLocked(0x736480, 0x2000, 0x0)
/usr/local/go/src/pkg/runtime/mheap.c:126 +0x305 fp=0x7fc88b846988
runtime.MHeap_Alloc(0x736480, 0x2000, 0x100000000, 0x1)
/usr/local/go/src/pkg/runtime/mheap.c:95 +0x7b fp=0x7fc88b8469b0
runtime.mallocgc(0x2000000, 0x525e81, 0x1)
/usr/local/go/src/pkg/runtime/malloc.goc:89 +0x484 fp=0x7fc88b846a20
cnew(0x525e80, 0x2000000, 0xc200000001)
/usr/local/go/src/pkg/runtime/malloc.goc:718 +0xc1 fp=0x7fc88b846a40
runtime.cnewarray(0x525e80, 0x2000000)
/usr/local/go/src/pkg/runtime/malloc.goc:731 +0x3a fp=0x7fc88b846a60
makeslice1(0x51daa0, 0x2000000, 0x2000000, 0x7fc88b846ac0)
/usr/local/go/src/pkg/runtime/slice.c:57 +0x4d fp=0x7fc88b846a78
runtime.makeslice(0x51daa0, 0x2000000, 0x2000000, 0xc21001ec80, 0x2000000, ...)
/usr/local/go/src/pkg/runtime/slice.c:38 +0x98 fp=0x7fc88b846aa8
loveoneanother.at/tiedot/file.OpenCol(0xc2100368a0, 0x2f, 0x2, 0xc2100368a0, 0x2f)
/root/shockwave/src/loveoneanother.at/tiedot/file/col.go:32 +0x77 fp=0x7fc88b846b18
loveoneanother.at/tiedot/db.OpenCol(0xc210036780, 0x2a, 0xc21001ec30, 0x0, 0x0)
/root/shockwave/src/loveoneanother.at/tiedot/db/col.go:56 +0x30c fp=0x7fc88b846bf8
loveoneanother.at/tiedot/db.OpenDB(0xc210036450, 0x21, 0xc21004c180, 0x0, 0x0)
/root/shockwave/src/loveoneanother.at/tiedot/db/db.go:30 +0x2bb fp=0x7fc88b846d10
main.main()
/root/shockwave/databank.go:355 +0x149 fp=0x7fc88b846f48
runtime.main()
/usr/local/go/src/pkg/runtime/proc.c:215 +0x11f fp=0x7fc88b846fa0
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1389 fp=0x7fc88b846fa8
goroutine 3 [syscall]:
os/signal.loop()
/usr/local/go/src/pkg/os/signal/signal_unix.go:21 +0x1e
created by os/signal.init·1
/usr/local/go/src/pkg/os/signal/signal_unix.go:27 +0x31
Can we work on reducing the memory footprint of tiedot per collection?