当前位置: 技术问答>linux和unix
有没有C函数可以取得内存的Total与Used呢?多谢!
来源: 互联网 发布时间:2015-03-17
本文导语: 在Linux中不用free命令, 有没有C函数可以取得内存的Total与Used呢?多谢! | NAME sysinfo - returns information on overall system statistics SYNOPSIS #include int sysinfo(struct...
在Linux中不用free命令,
有没有C函数可以取得内存的Total与Used呢?多谢!
有没有C函数可以取得内存的Total与Used呢?多谢!
|
NAME
sysinfo - returns information on overall system statistics
SYNOPSIS
#include
int sysinfo(struct sysinfo *info);
DESCRIPTION
Until Linux 2.3.16, sysinfo used to return 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 of shared memory */
unsigned long bufferram; /* Memory used by buffers */
unsigned long totalswap; /* Total swap space size */
unsigned long freeswap; /* swap space still available */
unsigned short procs; /* Number of current processes */
char _f[22]; /* Pads structure to 64 bytes */
};
sysinfo - returns information on overall system statistics
SYNOPSIS
#include
int sysinfo(struct sysinfo *info);
DESCRIPTION
Until Linux 2.3.16, sysinfo used to return 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 of shared memory */
unsigned long bufferram; /* Memory used by buffers */
unsigned long totalswap; /* Total swap space size */
unsigned long freeswap; /* swap space still available */
unsigned short procs; /* Number of current processes */
char _f[22]; /* Pads structure to 64 bytes */
};
|
读/proc/meminfo,free命令也是这样做的。
|
SYS_CONFIG()???
可以获得内存总页数,可用页数。
但函数名可能有误,记不清了
可以获得内存总页数,可用页数。
但函数名可能有误,记不清了