7

This question already has an answer here:

Related to my other question, I'm about to buy a new Mac Mini. I would like to reduce RAM to 8GB in order to see if 8GB is enough to my daily tasks in my MBP retina 15 early 2013 16GB RAM.

The idea is I’ll let this mac not make use of any more RAM than 8 GB for the running applications to see if they swap to disk or run well with 8 GB of RAM.

Can I do this sort of artificial restriction on a mac that has RAM soldered or when it’s inconvenient to go physically remove RAM for testing purposes?

marked as duplicate by Tetsujin, Allan macos Jan 29 at 0:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Now this is a great question. Since VM will make decisions differently as memory gets committed, you can’t just look at how much memory gets used on an older system and predict new. This question will get a bounty if we don’t get some good answers without one. @ me in comments if you don’t have any good answers in a week – bmike Jan 28 at 18:44
10

Create a ram disk :-)

From the answer to Mount a RAM disk on boot:

You can create and mount a RAM disk with the following Terminal (i.e. shell) command:

diskutil erasevolume HFS+ "diskName" $(hdiutil attach -nomount ram://2048)

Where 2048 can be any number and represents the number of 512 byte blocks you want to allocate. So 1,000,000 will get you 512,000,000 bytes. (Of course, you have to leave out the commas.)

So in your case the command would be

diskutil erasevolume HFS+ "diskName" $(hdiutil attach -nomount ram://$((8*2**30/512)))
  • I was thinking of a virtual machine but this is much simpler :) – Thorbjørn Ravn Andersen Jan 28 at 18:50
  • 😭for the 8 times 2^30 divided by 512 - that's awesome and a little harder to recognize at glance than our old friend 16777216 – bmike Jan 28 at 20:14
  • I was tongue in cheek - I love that you build up the exact request using math. : - ) It teaches several items where just dumping the number is correct, but not illuminating. Also, that operator order of precedence works is so cool, too. – bmike Jan 28 at 20:21
  • 1
    FWIW I keep a 2 GiB RAM disk and when first created diskimages-helper, which manages the RAM disk after being created by diskutil, is only ~33 MB and will grow as the RAM disk is filled up to the 2 GiB size. I think for an accurate test the RAM disk needs to be filled as it's not all used until it is. I'd use e.g. cat /dev/zero > /Volumes/diskName/foobar to have the designated amount of RAM actually used by the RAM disk... Otherwise I believe what is not used on the RAM disk size allotment is still available to the system. I could be wrong but that's my observation with this scenario. – user3439894 Jan 28 at 20:35
  • 4
    Would the ramdisk ever swap? – Freiheit Jan 28 at 20:40

Not the answer you're looking for? Browse other questions tagged .