获取ubuntu系统内存大小的小程序
2012-12-06 16:24
375 查看
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <linux/kernel.h>
static int print_memory_size(void)
{
int errorCode = 0;
struct sysinfo si;
errorCode = sysinfo(&si);
if (errorCode) {
printf("Failed to get memory type: %d \n", errorCode);
return -1;
}
printf("Total memory : %ld KB\n", (si.totalram / 1024));
return 0;
}
void main(void)
{
print_memory_size();
}
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <linux/kernel.h>
static int print_memory_size(void)
{
int errorCode = 0;
struct sysinfo si;
errorCode = sysinfo(&si);
if (errorCode) {
printf("Failed to get memory type: %d \n", errorCode);
return -1;
}
printf("Total memory : %ld KB\n", (si.totalram / 1024));
return 0;
}
void main(void)
{
print_memory_size();
}
相关文章推荐
- 怎样使用C语言程序获取Linux系统中未使用的内存大小? http://linux.cn/thread-13774-1-1.html
- android获取应用程序判断是系统程序还是应用程序并且判断在sd卡中还是内存中
- 获取手机系统大小、可用空间大小,设备可用内存及当前应用所占内存等
- 获取服务器信息shell脚本:内存大小,cpu型号,系统发行版本,硬盘个数及大小等
- 获取服务器信息shell脚本:内存大小,cpu型号,系统发行版本,硬盘个数及大小等
- 获取服务器信息shell脚本:内存大小,cpu型号,系统发行版本,硬盘个数及大小等
- 20170805Windows12_4_获取系统内存大小及空间内存
- 【系统信息获取】8,获取内存大小,可用内存大小
- 20170805Windows12_4_获取系统内存大小及空间内存
- Unity3D 程序获取当前系统剩余内存
- 20170805Windows12_4_获取系统内存大小及空间内存
- 【每日一句shell】获取系统内存大小
- Android获取当前系统存储/RAM/SD内存大小
- 获取系统内存大小(C#)
- linux bash脚本获取系统信息(cpu 总内存 可用内存 文件系统大小 系统位数 进程数 软件包数量 IP地址)
- 20170805Windows12_4_获取系统内存大小及空间内存
- 20170805Windows12_4_获取系统内存大小及空间内存
- 20170805Windows12_4_获取系统内存大小及空间内存
- 获取手机系统大小、可用空间大小,设备可用内存及当前应用所占内存等
- 获取系统内存显示程序