2009年3月25日星期三

Linux:Centos 如何释放内存


     当在Linux下频繁存取文件后,物理内存会很快被用光,当程序结束后,内存不会被正常释放,而是一直作为caching。因此,在系统备份(tar) 后,用top看的时候内存使用会吓你一大跳,用光了?

    先用 free -m 看看系统内存情况:

[oracle@server-centos01 ~]$ free -m
             total       used       free     shared    buffers     cached
Mem:          4047       4012         35          0         68       2509
-/+ buffers/cache:       1434       2613                                
Swap:         1906          0       1906


    其他的先别管,留意  

-/+ buffers/cache:       1434       2613        

    2613才是真正可用的内存,而不是total - used =free。

    那么,有没有办法释放这些内存呢,答案是有的。先看看以下的介绍:

/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.


    释放的方法:
   
    1.    sync
    2.    echo 3 >/proc/sys/vm/drop_caches


    再用 free -m 去看:

[root@server-centos01 ~]# free -m                     
             total       used       free     shared    buffers     cached
Mem:          4047       1652       2394          0          0        234
-/+ buffers/cache:       1417       2629                                
Swap:         1906          0       1906


    其实,如果不是用于调试,这类手工释放的方法建议还是不要去用。
   

2009年3月6日星期五

xorg.conf for Archlinux KDE 4.2.1 in HP Compaq nx7400

xorg.conf for Archlinux KDE 4.2.1 in HP Compaq nx7400

# /.../
# SaX generated X11 config file
# Created on: 2008-08-19T16:21:40+0800.
#
# Version: 8.1
# Contact: Marcus Schaefer <sax@suse.de>, 2005
# Contact: SaX-User list
<https://lists.berlios.de/mailman/listinfo/sax-users>
#
# Automatically generated by [ISaX] (8.1)
# PLEASE DO NOT EDIT THIS FILE!
#

Section "Files"
# FontPath "/usr/share/fonts/misc:unscaled"
FontPath "/usr/share/fonts/local"
FontPath "/usr/share/fonts/75dpi:unscaled"
FontPath "/usr/share/fonts/100dpi:unscaled"
FontPath "/usr/share/fonts/URW"
FontPath "/usr/share/fonts/Speedo"
FontPath "/usr/share/fonts/PEX"
FontPath "/usr/share/fonts/cyrillic"
FontPath "/usr/share/fonts/latin2/misc:unscaled"
FontPath "/usr/share/fonts/latin2/75dpi:unscaled"
FontPath "/usr/share/fonts/latin2/100dpi:unscaled"
FontPath "/usr/share/fonts/latin2/Type1"
FontPath "/usr/share/fonts/latin7/75dpi:unscaled"
FontPath "/usr/share/fonts/baekmuk:unscaled"
FontPath "/usr/share/fonts/japanese:unscaled"
FontPath "/usr/share/fonts/kwintv"
FontPath "/usr/share/fonts/truetype"
FontPath "/usr/share/fonts/uni:unscaled"
FontPath "/usr/share/fonts/CID"
FontPath "/usr/share/fonts/ucs/misc:unscaled"
FontPath "/usr/share/fonts/ucs/75dpi:unscaled"
FontPath "/usr/share/fonts/ucs/100dpi:unscaled"
FontPath "/usr/share/fonts/hellas/misc:unscaled"
FontPath "/usr/share/fonts/hellas/75dpi:unscaled"
FontPath "/usr/share/fonts/hellas/100dpi:unscaled"
FontPath "/usr/share/fonts/hellas/Type1"
FontPath "/usr/share/fonts/misc/sgi:unscaled"
FontPath "/usr/share/fonts/xtest"
FontPath "/opt/kde3/share/fonts"
InputDevices "/dev/gpmdata"
InputDevices "/dev/input/mice"
EndSection

Section "ServerFlags"
Option "AIGLX" "on"
Option "AllowMouseOpenFail" "on"
Option "ZapWarning" "on"
EndSection

Section "Module"
Load "glx"
#Load "type1"
Load "extmod"
Load "dbe"
Load "freetype"
Load "dri"
Load "synaptics"
EndSection

Section "InputDevice"
Driver "kbd"
Identifier "Keyboard[0]"
#Option "Protocol" "Standard"
Option "XkbLayout" "us"
#Option "XkbModel" "microsoftpro"
Option "XkbModel" "pc104"
#Option "XkbRules" "xfree86"
EndSection


Section "InputDevice"
Driver "mouse"
Identifier "Mouse[1]"
Option "Buttons" "5"
Option "Device" "/dev/input/mice"
Option "Name" "Pixart Imaging USB OPTICAL MOUSE"
Option "Protocol" "explorerps/2"
Option "Vendor" "Sysp"
Option "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
Driver "synaptics"
Identifier "Mouse[3]"
Option "Buttons" "5"
Option "Device" "/dev/input/mice"
Option "Emulate3Buttons" "on"
Option "HorizScrollDelta" "0"
Option "InputFashion" "Mouse"
Option "Name" "Synaptics;Touchpad"
Option "Protocol" "explorerps/2"
Option "SHMConfig" "on"
Option "Vendor" "Sysp"
Option "ZAxisMapping" "4 5"
EndSection


Section "Monitor"
DisplaySize 305 230
HorizSync 30-82
Identifier "Monitor[0]"
ModelName "1280X1024@60HZ"
Option "DPMS"
#Option "PreferredMode" "1280x1024"
VendorName "--> LCD"
VertRefresh 50-60
UseModes "Modes[0]"
EndSection


Section "Modes"
Identifier "Modes[0]"
# 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz
ModeLine "640x480" 25.2 640 656 752 800 480 490 492 525 -hsync -vsync
# # 640x480 @ 72Hz (VESA) hsync: 37.9kHz
ModeLine "640x480" 31.5 640 664 704 832 480 489 491 520 -hsync -vsync
# # 800x600 @ 56Hz (VESA) hsync: 35.2kHz
ModeLine "800x600" 36.0 800 824 896 1024 600 601 603 625 +hsync +vsync
# # 800x600 @ 60Hz (VESA) hsync: 37.9kHz
ModeLine "800x600" 40.0 800 840 968 1056 600 601 605 628 +hsync +vsync
# # 800x600 @ 72Hz (VESA) hsync: 48.1kHz
ModeLine "800x600" 50.0 800 856 976 1040 600 637 643 666 +hsync +vsync
# # 800x600 @ 75Hz (VESA) hsync: 46.9kHz
ModeLine "800x600" 49.5 800 816 896 1056 600 601 604 625 +hsync +vsync
# # 1024x768 @ 60Hz (VESA) hsync: 48.4kHz
ModeLine "1024x768" 65.0 1024 1048 1184 1344 768 771 777 806 -hsync -vsync
# # 1024x768 @ 70Hz (VESA) hsync: 56.5kHz
ModeLine "1024x768" 75.0 1024 1048 1184 1328 768 771 777 806 -hsync -vsync
# # 1024x768 @ 75Hz (VESA) hsync: 60.0kHz
ModeLine "1024x768" 78.8 1024 1040 1136 1312 768 769 772 800 +hsync +vsync
# # 1280x960 @ 60Hz (VESA) hsync: 60.0kHz
ModeLine "1280x960" 148.5 1280 1344 1504 1728 960 961 964 1011 +hsync
+vsync
# # 1280x1024 @ 60Hz (VESA) hsync: 64.0kHz
ModeLine "1280x1024" 108.0 1280 1328 1440 1688 1024 1025 1028 1066
+hsync +vsync
# # 1280x1024 @ 75Hz (VESA) hsync: 80.0kHz
ModeLine "1280x1024" 135.0 1280 1296 1440 1688 1024 1025 1028 1066
+hsync +vsync
# # 1600x1200 @ 60Hz (VESA) hsync: 75.0kHz
ModeLine "1600x1200" 162.0 1600 1664 1856 2160 1200 1201 1204 1250
+hsync +vsync
# # 1600x1200 @ 65Hz (VESA) hsync: 81.3kHz
ModeLine "1600x1200" 175.5 1600 1664 1856 2160 1200 1201 1204 1250
+hsync +vsync
# # 1600x1200 @ 70Hz (VESA) hsync: 87.5kHz
ModeLine "1600x1200" 189.0 1600 1664 1856 2160 1200 1201 1204 1250
+hsync +vsync
# # 1600x1200 @ 75Hz (VESA) hsync: 93.8kHz
ModeLine "1600x1200" 202.5 1600 1664 1856 2160 1200 1201 1204 1250
+hsync +vsync
EndSection


Section "Screen"
DefaultDepth 16
SubSection "Display"
Depth 15
Modes "1280x1024" "1280x960" "1280x800" "1152x864" "1280x768" "1280x720"
"1024x768" "1280x600" "1024x600" "800x600" "768x576" "640x480"
EndSubSection
SubSection "Display"
Depth 16
Modes "1280x1024" "1280x960" "1280x800" "1152x864" "1280x768" "1280x720"
"1024x768" "1280x600" "1024x600" "800x600" "768x576" "640x480"
EndSubSection
SubSection "Display"
Depth 24
Modes "1280x1024" "1280x960" "1280x800" "1152x864" "1280x768" "1280x720"
"1024x768" "1280x600" "1024x600" "800x600" "768x576" "640x480"
EndSubSection
SubSection "Display"
Depth 8
Modes "1280x1024" "1280x960" "1280x800" "1152x864" "1280x768" "1280x720"
"1024x768" "1280x600" "1024x600" "800x600" "768x576" "640x480"
EndSubSection
Device "Device[0]"
Identifier "Screen[0]"
Monitor "Monitor[0]"
EndSection


Section "Device"
BoardName "945 GM"
BusID "0:2:0"
Driver "intel"
Identifier "Device[0]"
Option "monitor-LVDS" "Monitor[0]"
Screen 0
VendorName "Intel"
#Option "AddARGBGLXVisuals" "True"
EndSection

Section "ServerLayout"
Identifier "Layout[all]"
InputDevice "Keyboard[0]" "CoreKeyboard"
InputDevice "Mouse[1]" "CorePointer"
InputDevice "Mouse[3]" "SendCoreEvents"
Option "Clone" "off"
Option "Xinerama" "off"
Screen "Screen[0]"
EndSection


Section "DRI"
Group "video"
Mode 0660
EndSection

Section "Extensions"
Option "Composite" "Enable"
EndSection