How to write a c++ program using linux system call which gives output about free memory, used memory, kernel version? -
on linux system, using c++ program, need find way print out following information:
- amount of memory in use.
- amount of free memory
- linux kernel version.
can me on how achieve this?
thank you.
you use proc(5) file system (it specific linux). might read sequentially /proc/meminfo
, /proc/version
(these pseudo-files should read sequentially, , quick, not involving disk io). use uname(2) version of kernel.
if want query virtual memory own process, use /proc/self/maps
if need information related malloc(3), use malloc_info(3), mallinfo(3), malloc_stats(3), ...
the comment mlwn mentions rightly sysconf(3)
see linuxatemyram. , read advanced linux programming
it possible limit used (or available) memory, see this answer. use getrlimit(2) query resource limits.
ps. mention of amount of memory in use very ambiguous! notice syscalls(2) not same system(3)
Comments
Post a Comment