NAME

meminfo - determine memory usage

SYNOPSIS

        C:

        typedef struct {
          long total;
          long free;
          long shared;
          long buffers;
          long cached;
          long swap_total;
          long swap_free;
        } MEMINFO;

        meminfo(MEMINFO *);

        Fortran:

        integer*8 mem(7)

        meminfo(mem)

        C++:

        typedef struct {
          long total;
          long free;
          long shared;
          long buffers;
          long cached;
          long swap_total;
          long swap_free;
        } MEMINFO;
        extern "C" void meminfo(MEMINFO *);

        meminfo(MEMINFO *);

DESCRIPTION

The meminfo fuction parses the Linux /proc/meminfo file and returns the memory usage information contained in the file for use by a C or Fortran program. Upon return (all reports are in bytes):

RETURN VALUES

Returns 0 on success, 1 if an error occured.

CAVEATS

You do NOT want to allocate all of the free memory. Because if you allocate this amount there will not be any memory left for other processes to use and function correctly. It would be a good rule of thumb to subtract 5 to 10 MBytes from this amount.