Chinaunix首页 | 论坛 | 博客
  • 博客访问: 424571
  • 博文数量: 161
  • 博客积分: 5005
  • 博客等级: 上校
  • 技术积分: 1090
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-20 16:38
文章分类

全部博文(161)

文章存档

2011年(21)

2010年(33)

2009年(89)

2008年(18)

我的朋友

分类: LINUX

2011-02-08 18:58:59

作者: 李春林
来源:

清理memory和swap是非常不好的, 但是如果你确实要这样做, 请先执行sync.

在2.6.16内核有个文件叫/proc/sys/vm/drop_caches, 看看它的用法就知道了.

/proc/sys/vm/drop_caches (since Linux 2.6.16)
Writing to this file causes the kernel to drop clean caches,
dentries and inodes from memory, causing that memory to become
free.

To free pagecache, use echo 1 > /proc/sys/vm/drop_caches; to
free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >
/proc/sys/vm/drop_caches.

Because this is a non-destructive operation and dirty objects
are not freeable, the user should run sync first.

交换分区呢? 看swapon, swapoff的手册就知道了..

Swapon is used to specify devices on which paging and swapping are to take place. Calls to swapon normally occur in the system multi-user initialization file /etc/rc making all swap devices available, so that the paging and swapping activity is interleaved across several devices and files.

Normally, the first form is used:

-h
Provide help 
-V
Display version 
-s
Display swap usage summary by device. Equivalent to "cat /proc/swaps". Not available before Linux 2.1.25. 
-a
All devices marked as ``swap'' swap devices in /etc/fstab are made available. Devices that are already running as swap are silently skipped. 
-e
When -a is used with swapon, -e makes swapon silently skip devices that do not exist. 
-p priority
Specify priority for swapon. This option is only available if swapon was compiled under and is used under a 1.3.2 or later kernel. priority is a value between 0 and 32767. See swapon(2) for a full description of swap priorities. Add pri=value to the option field of /etc/fstab for use with swapon -a. 

Swapoff disables swapping on the specified devices and files. When the -a flag is given, swapping is disabled on all known swap devices and files (as found in /proc/swaps or /etc/fstab).

阅读(815) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~