免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: ykyx00
打印 上一主题 下一主题

内存使用到多少时候开始使用swap ? [复制链接]

论坛徽章:
0
11 [报告]
发表于 2011-10-24 16:26 |只看该作者
60%

论坛徽章:
0
12 [报告]
发表于 2011-10-25 08:55 |只看该作者
应该是剩余60M 的时候开始使用!

论坛徽章:
0
13 [报告]
发表于 2011-10-25 08:57 |只看该作者
高手才有心情研究这个啊,菜鸟看了也是白看,等用到的时候就忘了

论坛徽章:
1
天秤座
日期:2013-10-23 13:20:42
14 [报告]
发表于 2011-10-25 11:16 |只看该作者
swap tendency = mapped ratio / 2 + distress + swappiness

The mapped ratio value is the percentage of pages in all memory zones that belong to User Mode address spaces (sc->nr_mapped) with respect to the total number of allocatable page frames. A high value of mapped_ratio means that the dynamic memory is mostly used by User Mode processes, while a low value means that it is mostly used by the page cache.

The distress value is a measure of how effectively the PFRA is reclaiming page frames in this zone; it is based on the scanning priority of the zone in the previous run of the PFRA, which is stored in the prev_priority field of the zone descriptor. The distress value depends on the zone's previous priority as follows:

Zone prev. priority
12...7
6
5
4
3
2
1
0

Distress value
0
1
3
6
12
25
50
100





Finally, the swappiness value is a user-defined constant, which is usually set to 60. The system administrator may tune this value by writing in the /proc/sys/vm/swappiness file or by issuing the proper sysctl( ) system call.

Pages will be reclaimed from the address spaces of processes only if the zone's swap tendency is greater than or equal to 100. Thus, if the system administrator sets swappiness to 0, then the PFRA never reclaims pages in the User Mode address spaces unless the zone's previous priority is zero (an unlikely event); if the administrator sets swappiness to 100, then the PFRA reclaims pages in the User Mode address spaces at every invocation.

swappiness,吃参数是得到swap tendency的一个量,而swap tendency是linux内核进行内存进行回收的一个阀值和标量。感觉和ls题目的说明还不尽相同

论坛徽章:
0
15 [报告]
发表于 2012-07-13 17:22 |只看该作者
首先是,kswapd进程来定期扫描系统资源,查看内存是否够用,由两个值影响pages_high和page_low,如果现在可使用的区间在page_high<x<page_low,就开始检查从文件系统读入的文件,有无被修改的内存页面,如果有就写入到磁盘,但是,如果内存页面被修改了,有可能不是从文件系统读入的,即找不到回写的位置,如malloc产生的anonymous内存数据就写入swap分区,这部分当进程在次被唤醒,获得了CPU运行时间,在从swap读入;
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP