1. Create RAM disk via terminal
A. Creating and mounting
Open the terminal application from the Application > Utility and enter the following command:
$diskutil erasevolume hfs+ ' RamDisk ' hdiutil attach-nomount ram://xxxxx ' replaces the x character with a number representing the block size of the RAM disk's total capacity. This number is computed by multiplying the required disk size by megabytes 2048来. In our example, we will create a 4 GB RAM disk that requires 8,388,608 quantities (4096x2048). Enter this number instead of the X characters in the above command:
$diskutil erasevolume hfs+ ' RamDisk ' hdiutil attach-nomount ram://8388608 ' B. Uninstall
$ diskutil unmount/volumes/ramdisk 2. Using C + + to perform mount and uninstall commands
#include <iostream>
#include <unistd.h>
using namespace std;
int main ()
{
system ("Diskutil erasevolume hfs+ ' ramdisk ' hdiutil attach-nomount '");
System ("Diskutil unmount/volumes/ramdisk/");
System ("Diskutil unmount/dev/disk7");
To build an executable program by compiling:
Mycall:mycall.cpp
g++ Mycall.cpp-o Mycall