一、功能介绍
通过sysinfo函数获取系统内存的使用情况。
sysinfo函数的帮助页如下:
wbyq@wbyq:/mnt/hgfs/linux-share-dir/linux_c$ man sysinfo
SYSINFO(2) Linux Programmer's Manual SYSINFO(2)
NAME
sysinfo - return system information
SYNOPSIS
#include
int sysinfo(struct sysinfo *info);
DESCRIPTION
sysinfo() returns certain statistics on memory and swap usage, as well as the load average.
Until Linux 2.3.16, sysinfo() returned information in the following structure:
struct sysinfo {
long uptime; /* Seconds since boot */
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
unsigned long totalram; /* Total usable main memory size */
unsigned long freeram; /* Available memory size */
unsigned long sharedram; /* Amount o