Thread: Program that displays amount of free memory

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    23

    Program that displays amount of free memory

    HI
    I would like to somthing like free function that displays amount of free memory in linux, so I want to write a program that displays amount of free memory on the system, so I suppose I have to use a function or something that displays memory data. It's not useful to type free -m to display amount of free memory, I need to have displayed amount of free memory at begining or end of some program........like...... amount of free memory = 480MB
    and then program runs forward. I know I described weird - the point is I need a line in program or program that tells to the system to display amount of free memory on the screen .
    Have a nice Day

    Matt

  2. #2
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Why didn't you post in the Linux programming forum?

    Anyway, I suggest you write a function that opens /proc/meminfo and extracts the data you need.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Moved

  4. #4
    !anExpert
    Join Date
    Mar 2005
    Location
    pa
    Posts
    155
    cwr is right, just read /proc/meminfo that is what free does anyhow..

    you can `cat /proc/meminfo` to see the format,
    and since free is free you can also get the source for free for free..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Determing the amount of change(money)
    By Kyeong in forum C Programming
    Replies: 11
    Last Post: 09-30-2008, 04:36 PM
  2. Replies: 12
    Last Post: 06-24-2005, 04:27 PM
  3. Locating A Segmentation Fault
    By Stack Overflow in forum C Programming
    Replies: 12
    Last Post: 12-14-2004, 01:33 PM
  4. insufficient memory for tsr
    By manmohan in forum C Programming
    Replies: 8
    Last Post: 01-02-2004, 09:48 AM