BUG: RAM won't overallocate, easily fixed, but considering options! #134

Closed
opened 2025-12-28 23:25:50 +01:00 by adam · 10 comments
Owner

Originally created by @sickcodes on GitHub (Mar 14, 2021).

I'm trying to run but i got this error Unable to init server: Could not connect: Connection refused qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory QEMU 5.2.0 monitor - type 'help' for more information (qemu)
Can anyone help me?
I am trying the start OSX with this command
sudo docker run --device /dev/kvm --device /dev/snd -v /tmp/X11-unix:/tmp/X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:latest

Originally posted by @C9-Dev in https://github.com/sickcodes/Docker-OSX/issues/131#issuecomment-798802122

Originally created by @sickcodes on GitHub (Mar 14, 2021). I'm trying to run but i got this error `Unable to init server: Could not connect: Connection refused qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory QEMU 5.2.0 monitor - type 'help' for more information (qemu)` Can anyone help me? I am trying the start OSX with this command `sudo docker run --device /dev/kvm --device /dev/snd -v /tmp/X11-unix:/tmp/X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:latest` _Originally posted by @C9-Dev in https://github.com/sickcodes/Docker-OSX/issues/131#issuecomment-798802122_
adam added the bug label 2025-12-28 23:25:50 +01:00
adam closed this issue 2025-12-28 23:25:50 +01:00
Author
Owner

@sickcodes commented on GitHub (Mar 14, 2021):

I'm trying to run but i got this error Unable to init server: Could not connect: Connection refused qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory QEMU 5.2.0 monitor - type 'help' for more information (qemu)
Can anyone help me?
I am trying the start OSX with this command
sudo docker run --device /dev/kvm --device /dev/snd -v /tmp/X11-unix:/tmp/X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:latest

@C9-Dev I am also getting this Issue, it is because the default RAM is 8GB, and in this case, the server has BELOW that amount and kills.

I am updating the image now, perhaps 90% of MemTotal's 8152908 kB?

[arch@40a8c6c0937c OSX-KVM]$ cat /proc/meminfo
MemTotal:        8152908 kB
MemFree:         5208916 kB
MemAvailable:    7394820 kB
Buffers:           55608 kB
Cached:          2309448 kB
SwapCached:            0 kB
Active:          1202276 kB
Inactive:        1496992 kB
Active(anon):     337280 kB
Inactive(anon):      584 kB
Active(file):     864996 kB
Inactive(file):  1496408 kB
Unevictable:       18460 kB
Mlocked:           18460 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:              1160 kB
Writeback:             0 kB
AnonPages:        352432 kB
Mapped:           311224 kB
Shmem:              1572 kB
KReclaimable:      87824 kB
Slab:             175728 kB
SReclaimable:      87824 kB
SUnreclaim:        87904 kB
KernelStack:        6660 kB
PageTables:         8404 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     4076452 kB
Committed_AS:    3280588 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       19568 kB
VmallocChunk:          0 kB
Percpu:             2944 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:      167916 kB
DirectMap2M:     2977792 kB
DirectMap1G:     5242880 kB
[arch@40a8c6c0937c OSX-KVM]$ 



@sickcodes commented on GitHub (Mar 14, 2021): > I'm trying to run but i got this error `Unable to init server: Could not connect: Connection refused qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory QEMU 5.2.0 monitor - type 'help' for more information (qemu)` > Can anyone help me? > I am trying the start OSX with this command > `sudo docker run --device /dev/kvm --device /dev/snd -v /tmp/X11-unix:/tmp/X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:latest` @C9-Dev I am also getting this Issue, it is because the default RAM is 8GB, and in this case, the server has BELOW that amount and kills. I am updating the image now, perhaps 90% of MemTotal's `8152908 kB`? ```console [arch@40a8c6c0937c OSX-KVM]$ cat /proc/meminfo MemTotal: 8152908 kB MemFree: 5208916 kB MemAvailable: 7394820 kB Buffers: 55608 kB Cached: 2309448 kB SwapCached: 0 kB Active: 1202276 kB Inactive: 1496992 kB Active(anon): 337280 kB Inactive(anon): 584 kB Active(file): 864996 kB Inactive(file): 1496408 kB Unevictable: 18460 kB Mlocked: 18460 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 1160 kB Writeback: 0 kB AnonPages: 352432 kB Mapped: 311224 kB Shmem: 1572 kB KReclaimable: 87824 kB Slab: 175728 kB SReclaimable: 87824 kB SUnreclaim: 87904 kB KernelStack: 6660 kB PageTables: 8404 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 4076452 kB Committed_AS: 3280588 kB VmallocTotal: 34359738367 kB VmallocUsed: 19568 kB VmallocChunk: 0 kB Percpu: 2944 kB HardwareCorrupted: 0 kB AnonHugePages: 0 kB ShmemHugePages: 0 kB ShmemPmdMapped: 0 kB FileHugePages: 0 kB FilePmdMapped: 0 kB CmaTotal: 0 kB CmaFree: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB Hugetlb: 0 kB DirectMap4k: 167916 kB DirectMap2M: 2977792 kB DirectMap1G: 5242880 kB [arch@40a8c6c0937c OSX-KVM]$
Author
Owner

@sickcodes commented on GitHub (Mar 14, 2021):

user 100% of ram

echo $(("$(head -n1 /proc/meminfo | tr -dc '[:digit:]') / 900000"))

90% ram

echo $(("$(head -n1 /proc/meminfo | tr -dc '[:digit:]') / 900000"))
RAM=${RAM:-$(("$(head -n1 /proc/meminfo | tr -dc '[:digit:]') / 900000"))}000 \
exec qemu-system-x86_64 -m ${RAM} \

Or shall I set the default RAM to 2000 as that's the bare minimum anyway?

@sickcodes commented on GitHub (Mar 14, 2021): user 100% of ram ```bash echo $(("$(head -n1 /proc/meminfo | tr -dc '[:digit:]') / 900000")) ``` 90% ram ```bash echo $(("$(head -n1 /proc/meminfo | tr -dc '[:digit:]') / 900000")) ``` ```bash RAM=${RAM:-$(("$(head -n1 /proc/meminfo | tr -dc '[:digit:]') / 900000"))}000 \ exec qemu-system-x86_64 -m ${RAM} \ ``` Or shall I set the default RAM to 2000 as that's the bare minimum anyway?
Author
Owner

@yansigit commented on GitHub (Mar 18, 2021):

Hi, I'm still getting same issue

user@pc:~$ docker run -it \
>     --device /dev/kvm \
>     -p 50922:10022 \
>     -v /tmp/.X11-unix:/tmp/.X11-unix \
>     -e "DISPLAY=${DISPLAY:-:0.0}" \
>     sickcodes/docker-osx:latest
touch: cannot touch '': No such file or directory
chown: cannot access '': No such file or directory
ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519 
nohup: appending output to 'nohup.out'
qemu-system-x86_64: warning: dbind: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-TT9MRS7Axy: Connection refused
QEMU 5.2.0 monitor - type 'help' for more information
(qemu) qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory

I've checked /dev/kvm permissions, xhost +, and if user in groups of libvirt, docker and kvm groups.
I'm not running in root account either.

I'm using these images

user@pc:~$ docker images
REPOSITORY             TAG       IMAGE ID       CREATED        SIZE
sickcodes/docker-osx   big-sur   24f7759e905b   21 hours ago   3.25GB
sickcodes/docker-osx   latest    45c4d709ad41   21 hours ago   3.08GB
@yansigit commented on GitHub (Mar 18, 2021): Hi, I'm still getting same issue ``` user@pc:~$ docker run -it \ > --device /dev/kvm \ > -p 50922:10022 \ > -v /tmp/.X11-unix:/tmp/.X11-unix \ > -e "DISPLAY=${DISPLAY:-:0.0}" \ > sickcodes/docker-osx:latest touch: cannot touch '': No such file or directory chown: cannot access '': No such file or directory ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519 nohup: appending output to 'nohup.out' qemu-system-x86_64: warning: dbind: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-TT9MRS7Axy: Connection refused QEMU 5.2.0 monitor - type 'help' for more information (qemu) qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory ``` I've checked /dev/kvm permissions, xhost +, and if user in groups of libvirt, docker and kvm groups. I'm not running in root account either. I'm using these images ``` user@pc:~$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE sickcodes/docker-osx big-sur 24f7759e905b 21 hours ago 3.25GB sickcodes/docker-osx latest 45c4d709ad41 21 hours ago 3.08GB ```
Author
Owner

@sickcodes commented on GitHub (Mar 19, 2021):

How much RAM do you have

@sickcodes commented on GitHub (Mar 19, 2021): How much RAM do you have
Author
Owner

@yansigit commented on GitHub (Mar 19, 2021):

@sickcodes i have 16GB size rams

@yansigit commented on GitHub (Mar 19, 2021): @sickcodes i have 16GB size rams
Author
Owner

@sickcodes commented on GitHub (Mar 19, 2021):

Try now since I changed f6e0bfa202

Default RAM is 3GB, you can change to something like 5 or 10 because it will use all of it

-e RAM=5 \

@sickcodes commented on GitHub (Mar 19, 2021): Try now since I changed https://github.com/sickcodes/Docker-OSX/commit/f6e0bfa202b4cc7d8cea50bb98b0655125a3a0cb Default RAM is 3GB, you can change to something like 5 or 10 because it will use all of it `-e RAM=5 \`
Author
Owner

@sickcodes commented on GitHub (Mar 19, 2021):

Another suitable candidate for increasing available RAM:

sync; echo 3 > /proc/sys/vm/drop_caches

Which clears your memory cache.

@sickcodes commented on GitHub (Mar 19, 2021): Another suitable candidate for increasing available RAM: `sync; echo 3 > /proc/sys/vm/drop_caches` Which clears your memory cache.
Author
Owner

@sickcodes commented on GitHub (Mar 19, 2021):

I removed RAM=max and changed the default to 3

export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 1000000"))"'

^This causes RAM creep. I left an idling machine on for 10 hours and I used about 16 of RAM by the end of it.

2GB is also slightly too small and causes mouse freezes (personally experienced, and seen in https://github.com/sickcodes/Docker-OSX/issues/207)

From the following reddit comment:
https://www.reddit.com/r/Proxmox/comments/8sy4sd/unable_to_start_vm/e13ghrz/?utm_source=reddit&utm_medium=web2x&context=3

@sickcodes commented on GitHub (Mar 19, 2021): I removed `RAM=max` and changed the default to 3 ```bash export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 1000000"))"' ``` ^This causes RAM creep. I left an idling machine on for 10 hours and I used about 16 of RAM by the end of it. 2GB is also slightly too small and causes mouse freezes (personally experienced, and seen in https://github.com/sickcodes/Docker-OSX/issues/207) From the following reddit comment: https://www.reddit.com/r/Proxmox/comments/8sy4sd/unable_to_start_vm/e13ghrz/?utm_source=reddit&utm_medium=web2x&context=3
Author
Owner

@sickcodes commented on GitHub (Mar 24, 2021):

sudo tee /proc/sys/vm/drop_caches <<< 3

@sickcodes commented on GitHub (Mar 24, 2021): `sudo tee /proc/sys/vm/drop_caches <<< 3`
Author
Owner

@gspagoni commented on GitHub (Aug 12, 2024):

Try now since I changed f6e0bfa

Default RAM is 3GB, you can change to something like 5 or 10 because it will use all of it

-e RAM=5 \

How can i specify 16GB, can you post the full command please?

@gspagoni commented on GitHub (Aug 12, 2024): > Try now since I changed [f6e0bfa](https://github.com/sickcodes/Docker-OSX/commit/f6e0bfa202b4cc7d8cea50bb98b0655125a3a0cb) > > Default RAM is 3GB, you can change to something like 5 or 10 because it will use all of it > > `-e RAM=5 \` How can i specify 16GB, can you post the full command please?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Docker-OSX#134