Docker Community Forums

Share and learn in the Docker community.

C++ code compiling error - virtual memory exhausted: Operation not permitted


(Lijunqin2008) #1

My system:
(1) Docker - Server Version: 18.03.1-ce running over x64 Ubuntu Virtual Machine hosted on EXSI 6.5
(2) 32-Bit ubuntu.12.04 with ARM cross compiler gcc 4.8.2
(3) x64 Ubuntu - 8 CPU cores - 64G RAM
(4) My C++ code cross compiles OK directly on x64 Ubuntu Virtual Machine, but container over this VM gets
error: virtual memory exhausted: Operation not permitted
Any help is greatly appreciated, I am just a beginner with docker.
Some additional info is attached,
Thank you
Lijun


arm-gcc:
Using built-in specs.
COLLECT_GCC=./arm-none-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/opt/arm-2013.11/bin/…/libexec/gcc/arm-none-linux-gnueabi/4.8.2/lto-wrapper
Target: arm-none-linux-gnueabi
gcc version 4.8.2 20131014 (prerelease) (crosstool-NG hg+default-9838aecd6340 - tc0003)

dfvsmdev@galileo-docker-qin:~/workspace/yoda/vendor$ free -m
total used free shared buff/cache available
Mem: 64424 328 38934 9 25161 63286
Swap: 75811 0 75811

dfvsmdev@galileo-docker-qin:~/workspace/yoda/vendor$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 1
Core(s) per socket: 2
Socket(s): 4
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 63
Model name: Intel® Xeon® CPU E5-2650 v3 @ 2.30GHz
Stepping: 2
CPU MHz: 2297.339
BogoMIPS: 4594.67
Hypervisor vendor: VMware
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 25600K
NUMA node0 CPU(s): 0-7
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc cpuid aperfmperf pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx hypervisor lahf_lm epb pti retpoline dtherm ida arat pln pts
dfvsmdev@galileo-docker-qin:~/workspace/yoda/vendor$

dfvsmdev@galileo-docker-qin:~/workspace/yoda/vendor$ docker info
Containers: 12
Running: 2
Paused: 0
Stopped: 10
Images: 6
Server Version: 18.03.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.13.0-43-generic
Operating System: Ubuntu 16.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 62.91GiB
Name: galileo-docker-qin
ID: L4ZF:ZOFL:MG5N:PSWO:RBMI:74XH:AZGO:GTRG:7AIL:WYHY:UZKT:E7EK
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support
dfvsmdev@galileo-docker-qin:


(Antonindrawan) #2

Some time ago, I observed the same issue with a similar setup as your system.
I used ARM cross compiler gcc 4.8.3. The cross compiler is a 32-bit executable. Basically, it can’t allocate more than 4 GB RAM.

A workaround is to pass extra compiler flags “–param ggc-min-expand=1 --param ggc-min-heapsize=512000” when compiling source files.

ggc-min-heapsize is the minimum size of the garbage collector’s heap before it begins bothering to collect garbage. In that example, I set it to ~512 MB, if I am not mistaken.

Also read : https://stackoverflow.com/questions/16371939/reduce-memory-usage-in-boost-build/16372032