发现内存大量闲置,又闲的蛋疼,于是决定分出2G内存给浏览器做Cache。
1. 步骤
1.1.
将以下分隔符内代码保存为ramdisk.sh & chmod +x
ramedisk.sh---
ramdisk.sh-----
#!/bin/sh
mount_point=/Volumes/ramdisk
ramfs_size_mb=2048
RamDisk (){
ramfs_size_sectors=$((${ramfs_size_mb}*1024*1024/512))
ramdisk_dev=`hdid -nomount ram://${ramfs_size_sectors}`
newfs_hfs -v 'RAM Disk' ${ramdisk_dev}
mkdir -p ${mount_point}
mount -o noatime -t hfs ${ramdisk_dev} ${mount_point}
mkdir ${mount_point}/chrome
mkdir ${mount_point}/firefox
mkdir ${mount_point}/safari
rm ~/Library/Caches/Google/Chrome/Default/Cache
rm ~/Library/Caches/com.apple.Safari
ln -s ${mount_point}/chrome ~/Library/Caches/Google/Chrome/Default/Cache
ln -s ${mount_point}/safari ~/Library/Caches/com.apple.Safari
}
RamDisk
----eof-----------
1.2.
将ramedisk.sh 加入当前用户的启动项 [System Preferences->System->Accounts->Login Items]
1.3. Firefox需要另外设置 about:config中添加browser.cache.disk.parent_directory项,类型为string,值为 /private/ramdisk/firefox/
2. 磁盘速度测试(单位为M/S):
2.1. HD
2011-04-08 22:34:29.420 AJA System Test[10449:1707] Average read rate = 51.95
2011-04-08 22:34:29.421 AJA System Test[10449:1707] Average write rate = 54.03
2.2. RAMDISK
2011-04-08 22:34:53.170 AJA System Test[10449:1707] Average read rate = 1642.24
2011-04-08 22:34:53.171 AJA System Test[10449:1707] Average write rate = 1835.27
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/11184
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.