You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
os.totalmem() incorrect when called on container (LXD) #27170
os.totalmem() reports an invalid value when use on a continaer - tested on lxd -
How reproduce:
apt install lxd
lxd init
# .....
lxc launch ubuntu:18.04 machine1
lxc config set machine1 limits.memory 2500MB
lxc exec machine1 /bin/bash
# install node ......
node
>os.totalmem()
32xxxxxxxxxx // 32GB
# result here is the total memory of host no the container
os.totalmem() makes a sysinfo(2) system call to get the total memory (IOW, it merely reports what the operating system reports); htop on the other hand reads from /proc/meminfo, which lxcfs intercepts.
Libuv prefers sysinfo(2) for reasons of portability and robustness (/proc isn't always mounted) but I guess it could try /proc/meminfo first and fall back to sysinfo(2).
I'll close this out and open a new issue over at libuv/libuv. Thanks for the report.
Reacted by Ruben Bridgewater and Michael James (Kodhe)
Activity
bnoordhuis commentedon Apr 10, 2019
os.totalmem()makes a sysinfo(2) system call to get the total memory (IOW, it merely reports what the operating system reports); htop on the other hand reads from /proc/meminfo, which lxcfs intercepts.Libuv prefers sysinfo(2) for reasons of portability and robustness (/proc isn't always mounted) but I guess it could try /proc/meminfo first and fall back to sysinfo(2).
I'll close this out and open a new issue over at libuv/libuv. Thanks for the report.
deps: upgrade to libuv 1.29.1
deps: upgrade to libuv 1.29.1
deps: upgrade to libuv 1.29.1