Chinaunix首页 | 论坛 | 博客
  • 博客访问: 534934
  • 博文数量: 142
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1452
  • 用 户 组: 普通用户
  • 注册时间: 2013-09-12 16:28
文章分类

全部博文(142)

文章存档

2016年(10)

2015年(60)

2014年(72)

我的朋友

分类: LINUX

2015-11-09 15:42:21

如何查看Linux系统的内存页大小:
1. getconf PAGESIZE/PAGE_SIZE  返回值单位为Bytes

点击(此处)折叠或打开

  1. [root@localhost nginx-1.8.0]# getconf PAGESIZE
  2. 4096
  3. [root@localhost nginx-1.8.0]# getconf PAGE_SIZE
  4. 4096
2. 通过c函数获取
  #include
   int getpagesize(void);返回值单位为Bytes


点击(此处)折叠或打开

  1. The function getpagesize() returns the number of bytes in a page, where a "page" is the thing used where it says in the description of mmap(2) that files are mapped in page-sized units.

  2.        The size of the kind of pages that mmap() uses, is found using

  3.               #include <unistd.h>
  4.               long sz = sysconf(_SC_PAGESIZE);

  5.        (where some systems also allow the synonym _SC_PAGE_SIZE for _SC_PAGESIZE), or

  6.               #include <unistd.h>
  7.               int sz = getpagesize()
pagesize.c

点击(此处)折叠或打开

  1. [root@localhost test]# more pagesize.c
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. int main(int argc, char *argv[])
  5. {
  6.     printf("linux page size is %d bytes\n",getpagesize());
  7.     return 0;
  8. }
编译运行:

点击(此处)折叠或打开

  1. [root@localhost test]# gcc -g pagesize.c -o pagesize -Wall
  2. [root@localhost test]# ./pagesize
  3. linux page size is 4096 bytes





阅读(7118) | 评论(0) | 转发(0) |
0

上一篇:.gitignore文件无法过滤

下一篇:匿名 mmap

给主人留下些什么吧!~~