[FAQ] fatal error: runtime: out of memory

[问题澄清]

TiDB无法启动,tidb_stderr.log报错:

fatal error: runtime: out of memory

[原因分析]

用户修改了操作系统的内存使用策略

echo 2 > /proc/sys/vm/overcommit_memory

[解决方案]

设置echo 0 > /proc/sys/vm/overcommit_memory

[参考案例]

修改内存使用策略导致 TiDB自动下线后 无法启动

[学习引申点]

linux下overcommit_memory的问题

https://blog.csdn.net/houjixin/article/details/46412557

我这边在执行 tiup playground 也遇到了类似问题,修改内存策略之后依然有问题:
[root@VM-0-5-centos tidb]# tiup playground
The component playground version is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/playground-v1.4.1-linux-amd64.tar.gz 7.03 MiB / 7.03 MiB 100.00% 3.75 MiB p/s
Starting component playground: /root/.tiup/components/playground/v1.4.1/tiup-playground
Use the latest stable version: v5.0.0

Specify version manually:   tiup playground <version>
The stable version:         tiup playground v4.0.0
The nightly version:        tiup playground nightly

Playground Bootstrapping…
The component prometheus version v5.0.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/prometheus-v5.0.0-linux-amd64.tar.gz 39.84 MiB / 39.84 MiB 100.00% 8.19 MiB p/s
download https://tiup-mirrors.pingcap.com/grafana-v5.0.0-linux-amd64.tar.gz 54.28 MiB / 54.28 MiB 100.00% 4.33 MiB p/s
Start pd instance
The component pd version v5.0.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/pd-v5.0.0-linux-amd64.tar.gz 41.09 MiB / 41.09 MiB 100.00% 10.12 MiB p/s
Start tikv instance
The component tikv version v5.0.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tikv-v5.0.0-linux-amd64.tar.gz 161.21 MiB / 161.21 MiB 100.00% 9.50 MiB p/s
Start tidb instance
The component tidb version v5.0.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tidb-v5.0.0-linux-amd64.tar.gz 45.73 MiB / 45.73 MiB 100.00% 5.50 MiB p/s
Waiting for tidb instances ready
127.0.0.1:4000 … Done
Start tiflash instance
The component tiflash version v5.0.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tiflash-v5.0.0-linux-amd64.tar.gz 407.93 MiB / 407.93 MiB 100.00% 3.73 MiB p/s

fatal error: runtime: out of memory

runtime stack:
runtime.throw(0x563b1248560b, 0x16)
runtime/panic.go:1117 +0x74
runtime.sysMap(0xc028000000, 0x20000000, 0x563b131f37b0)
runtime/mem_linux.go:169 +0xc7
runtime.(*mheap).sysAlloc(0x563b131da120, 0x20000000, 0x563b11aed497, 0x563b131da128)
runtime/malloc.go:729 +0x1d4
runtime.(*mheap).grow(0x563b131da120, 0x10000, 0x0)
runtime/mheap.go:1346 +0x85
runtime.(*mheap).allocSpan(0x563b131da120, 0x10000, 0xc0004d0100, 0x563b11b2b6a5)
runtime/mheap.go:1173 +0x609
runtime.(*mheap).alloc.func1()
runtime/mheap.go:910 +0x5a
runtime.systemstack(0xc0005cd980)
runtime/asm_amd64.s:379 +0x63
runtime.mstart()
runtime/proc.go:1246

goroutine 1 [running]:
runtime.systemstack_switch()
runtime/asm_amd64.s:339 fp=0xc00014cab8 sp=0xc00014cab0 pc=0x563b11b318c0
runtime.(*mheap).alloc(0x563b131da120, 0x10000, 0xc000140101, 0x563b11b2e7c5)
runtime/mheap.go:904 +0x85 fp=0xc00014cb08 sp=0xc00014cab8 pc=0x563b11ae9125
runtime.(*mcache).allocLarge(0x7f9c7abe7108, 0x1ffffe00, 0xc01c830101, 0x8000000)
runtime/mcache.go:224 +0x99 fp=0xc00014cb60 sp=0xc00014cb08 pc=0x563b11ad96d9
runtime.mallocgc(0x1ffffe00, 0x563b12a69360, 0x1, 0xc005b6a138)
runtime/malloc.go:1078 +0x945 fp=0xc00014cbe8 sp=0xc00014cb60 pc=0x563b11acf2a5
runtime.makeslice(0x563b12a69360, 0x1ffffe00, 0x1ffffe00, 0xc01c839e00)
runtime/slice.go:98 +0x6e fp=0xc00014cc18 sp=0xc00014cbe8 pc=0x563b11b1206e
bytes.makeSlice(0x1ffffe00, 0x0, 0x0, 0x0)
。。。。。。。