4 ms·
Is there any syscall to do the equivalent but from C? e.g. If you were pre-allocating hash tables for a caching service, it would be convenient if the config c
by jorangreef 6y ago
Is there any syscall to do the equivalent but from C?
e.g. If you were pre-allocating hash tables for a caching service, it would be convenient if the config could stipulate 80% of the system memory instead of the user having to specify the exact amount.
- firethief 6y agoUse /proc/meminfo. What could a caching service possibly care about the bit of memory that is reserved for system use? It's not getting its hands on those pages under any circumstances. There is no interface for that information because at the level of abstraction at which userspace applications operate, that information has no meaning.
- deleted 6y ago[deleted]
- jwilk 6y agohttps://www.gnu.org/software/libc/manual/html_node/Query-Memory-Parameters.html https://www.gnu.org/software/libc/manual/html_node/Query-Mem... https://man7.org/linux/man-pages/man2/sysinfo.2.html https://man7.org/linux/man-pages/man2/sysinfo.2.html
- isatty 6y agoAs a comment above already mentioned - you should not try to work around and find the size of the physical memory installed because it often has no correlation to the amount of memory available to the kernel (and, to the user).