Advertisement

Available system memory

Started by September 19, 2002 04:34 PM
3 comments, last by krad7 22 years, 4 months ago
How do you find the available system memory using a c or c++ program??? is there any command.. any help would be greatly appreciated.. thanx Rrrrrrrrrrrromeo
Slow and steady wins the race.
You can use the ''free'' command to get a breakdown of current memory status:
$ free
total used free shared buffers cached
Mem: 255860 251336 4524 0 10532 149312
-/+ buffers/cache: 91492 164368
Swap: 393112 260 392852


But I don''t know of an equivalent function call.

-Sypro
Advertisement
Also, you can use ''top'' to see how much cpu and memory a program is using...

/Mikael
I don''t know of a function either, but you can manually parse /proc/meminfo (assuming Linux with /proc enabled).

IRIX 6.5, SunOS 5.2 : getrlimit() (in sys/resource.h)
I can''t get to the man pages on the local linux box.

Check your man pages for details ( brk() and sbrk() are a good starting point )

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement