RAM Disk on Mac

原文链接:http://www.toutiao.com/a6412375956519403778/?tt_from=weixin&utm_campaign=client_share&app=news_article&utm_source=weixin&iid=9729151087&utm_medium=toutiao_ios&wxshare_count=1

实现方法

方法的思路很简单,大概可以分两步:

1.配置 RAM。在内存中专门开出一块让 Xcode 使用。

2.连接 Xcode。让 Xcode 连接到我们开辟出来的专属内存空间。

下面就是见证奇迹的时刻。

第一步, 创建 .sh 文件。代码如下

#!/bin/bash
RAMDISK="ramdisk" SIZE=1024 #size in MB for ramdisk.·
diskutil erasevolume HFS+ $RAMDISK `hdiutil attach -nomount ram://$[SIZE*2048]`

第二步, 运行 .sh 文件。在命令行中敲下

之后你会发现你会多出一个叫 ramdisk 的内存空间,有大概 1 GB 大小。

第三步,连接 Xcode。Xcode -> Preferences -> Locations -> Locations Tab,配置 DerivedData。

Advanced… 也要配置成下图所示

以上就是全部步骤。这时候你就可以享受飞一般的开发了。现在 Project 中所有文件都在内存中,相比于 SSD,理论上是要快上一个数量级。

About Tang

A mobile developer, work in Stockholm, Sweden
This entry was posted in Mac. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s