linux free drop_cache 释放内存

Drop Caches

Kernels 2.6.16 and newer provide a mechanism to have the kernel drop the page cache and/or inode and dentry caches on command, which can help free up a lot of memory. Now you can throw away that script that allocated a ton of memory just to get rid of the cache...

To use /proc/sys/vm/drop_caches, just echo a number to it.

To free pagecache:

  # echo 1 > /proc/sys/vm/drop_caches 

To free dentries and inodes:

  # echo 2 > /proc/sys/vm/drop_caches 

To free pagecache, dentries and inodes:

  echo 3 > /proc/sys/vm/drop_caches 

This is a non-destructive operation and will only free things that are completely unused. Dirty objects will continue to be in use until written out to disk and are not freeable. If you run "sync" first to flush them out to disk, these drop operations will tend to free more memory.

tar 压缩解压常用命令

一直都只记着用tar命令怎么给gz的文件解压缩。可是,一旦下到个bz2的文件就不知道怎么处理了。

这就是知识不扎实的结果,无奈,只好仔细查一下man手册,和向“鸟哥”请教。

现记录一下,呵呵。高手勿怪。

tar [-cxtzjvfpPN] 文件与目录

参数:

-c :建立压缩文件的参数命令(creat的意思)

-x :解压缩文件的参数命令

-t :查看tar包里文件的命令特别注意,在使用参数时,c/x/t只能有一个,不能同时存在
因为不可能同时压缩与解压缩。

-z :是否同时具有gzip的属性,即是否需要用gzip压缩

-j :是否同时具有bz2的属性,即是否需要用bzip2压缩(记不住的就是它)

-v :压缩过程中显示文件,这个常用,呵基本上我现在每次解压都会看一下里面的文件

-f :使用文件名,之后立即加文件名,不能再加别的参数

-p :使用原文件的原来属性(属性不会根据用户而变),这个从来没用过。。

-P :可以使用绝对路径来压缩

-N :比后面接的日期(yyyy/mm/dd)还要新的才会被打包进新建的文件中

–exclude FILE :在压缩的过程中,不要将FILE打包

呵,基本上我现在常用的四个命令如下:

压缩成gzip文件:

tar -zcvf shell.tar.gz shell/

将gzip文件解压:

tar -zxvf shell.tar.gz

压缩为bz2文件:

tar -jcvf shell.tar.bz2 shell/

将bz2文件解压:

tar -jxvf shell.tar.bz2

==============2010.05.26补充============

如果只想将文件打成tar包,不做压缩,同样很简单:

tar -cvf shell.tar shell/

同样,解压你也就知道了

tar -xvf shell.tar

220 busybox ping探测mtu大小


 
/ # ping   192.168.3.1  -s 1472 -b
 
s表示包大小
-b表示禁止分片
 
ping的最大包长是1472

安装office 2010后,电脑启动变慢,主要是网卡启动很慢 解决方法

到服务中禁用Microsoft .NET Framework NGEN v4.0.30319_X86,理由如下:


 安装完VS2010后,默认会安装.Net 4.0的类库,但是这个安装后系统会更新一个补丁,并且开机会自动启动Microsoft .NET Framework NGEN v4.0.30319_X86服务,在xp系统中


会是网络连接延迟大约1分钟才会正常启动,根据官网的说法(http://msdn.microsoft.com/zh-tw/magazine/cc163610.aspx)会提示效能,但是如果不是必须的,还是在服务中将此服务禁用,至少我目前没发现会出现什么问题,但是这个服务开启的话,会让你的网卡启动很慢...

dlopen export dynamic

先看看状况(小心头疼)

client.c 编译得到 client;在 client 的 main 中用 dlopen( "./liba.so", RTLD_LAZY|RTLD_GLOBAL) 打开 liba.so,并调用 liba.so 中的 start 函数;在 liba.so 的 start 函数中通过 dlopen( 0, RTLD_GLOBAL|RTLD_LAZY ) 得到的句柄尝试调用 client  中的 startup_fcn 函数。使用 gcc client.c -o client -ldl 得到的 client 与 gcc -fPIC -shared liba.c -o liba.so 得到的 liba.so 的时候发现 liba.so 无法找到 client 中定义的 startup_fcn 函数。后经 pacman2k 大侠的提醒,发现了 ld 的参数 -E / --export-dynamic。使用 gcc -Wl,-E client.c -o client 重新编译 client 程序之后就可以成功调用了。

关于 -E 参数:

       -E
       --export-dynamic
           When  creating  a  dynamically  linked  executable, add all symbols to the dynamic symbol table.  The
           dynamic symbol table is the set of symbols which are visible from dynamic objects at run time.

           If you do not use this option, the dynamic symbol table will  normally  contain  only  those  symbols
           which are referenced by some dynamic object mentioned in the link.

           If  you use "dlopen" to load a dynamic object which needs to refer back to the symbols defined by the
           program, rather than some other dynamic object, then you will probably need to use this  option  when
           linking the program itself.
最后一段正说道这种『回调的情况』

关于 RTLD_GLOBAL

经测试,所有 dlopen 均取消 RTLD_GLOBAL 参数之后,仍然运行正常。RTLD_GLOBAL 参数的作用有待考察。