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:

  1. amount of memory in use.
  2. amount of free memory
  3. 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

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -