31

I've got two 2009 Macbooks. One has 4 gigs of RAM and runs os 10.10; one has 2 gigs and runs os 10.5.

I'm considering upgrading the latter machine to Yosemite (10.10), but I'm worried that it will run slowly with so little RAM. In order to get a sense of what the performance would be like, I'm wondering if there's some way I could "turn off" half the RAM in the higher spec machine. If I did this, I could get a sense of how Yosemite would run on the 2 gig machine before actually doing the upgrade.

Is there some way to temporarily disable RAM without physically removing the chip?

4
  • Why is not removing the chip a requirement? Couldn't you just swap the physical RAM of the two MacBooks? Apr 3, 2015 at 19:47
  • 4
    I don't have the right screwdriver handy.
    – dB'
    Apr 3, 2015 at 19:49
  • 3
    2009 MacBook Pro will accept DDR3 1333 MHz ram (it will down-speed to 1066mhz). You can purchase for $30. These machines will take up to 8gb. Add an SSD and this is still a very decent machine. Apr 4, 2015 at 6:10
  • @dB' Please accept OSdweeb's answer. instead of mine. Though you have to restart, it's an elegant and the default method and it delivers a more reliable result for 10.9/10.10 and probably later. The RAM disk works well for Mac OS X up to 10.8 without restart and tampering with system files.
    – klanomath
    Apr 5, 2015 at 5:50

6 Answers 6

26

There's no need to take out RAM, create a RAM disk or use a VM. Simply boot the OS using the maxmem= boot flag value that's been created for this purpose and been around for decades.

Simply open Terminal as a sudoer and enter

sudo nano /Library/Preferences/SystemConfiguration/com.apple.Boot.plist

After entering your password change

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs$
<plist version="1.0">
<dict>
        <key>Kernel Flags</key>
        <string></string>
</dict>
</plist>

to

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs$
<plist version="1.0">
<dict>
        <key>Kernel Flags</key>
        <string>maxmem=2048</string>
</dict>
</plist>

and write the changes to disk with ctrlo and quit nano with ctrlx

Restart your Mac to apply the changes.

To revert the changes remove 'maxmem=2048' with nano again.

4
  • 2
    My brain is an old garbage can... Yesterday I tried to find this easy solution come hell or high water - and I knew it exists - but I just didn't remember it.
    – klanomath
    Apr 4, 2015 at 11:38
  • 1
    Just by the way: you'd better complete the registration, otherwise if you accidentally lose your cookies, you won't be able to log in your account anymore.
    – nicael
    Apr 5, 2015 at 8:40
  • While this answer, as written on Apr 4 '15, may have worked on OS X through OS X 10.10 Yosemite; however, it no longer works on OS X 10.11 El Capitan and later unless one first disables System Integrity Protection. See How to modify System Integrity Protection in El Capitan, and while its directions are for El Capitan nonetheless, the same basic instructions apply for newer versions of macOS. Jan 29, 2019 at 16:04
  • Tried this and it's not working - Activity Monitor still says it's using 8GB in apps and 6GB in cached files out of my 16GB, when I set maxmem=8192... help! Apr 19, 2022 at 0:08
14

Just create a RAM Disk with the size 2 GiB to reduce available RAM for the system and running applications.

To get the necessary number of blocks to create such a disk, multiply (RAMdiskSize in MB)*2048. In your example that's 2048*2048=4194304.

Then open Terminal and enter:

diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nomount ram://4194304`

You will get a message similar to that one:

Started erase on disk9  
Unmounting disk  
Erasing  
Initialized /dev/rdisk9 as a 2 GB HFS Plus volume  
Mounting disk  
Finished erase on disk9 RAM Disk  

then use dd and the path to the volume and fill the disk with random data:

dd if=/dev/random of=/Volumes/RAM\ Disk/random.dat bs=1024k

The command will write 1 MiB chunks of random data to the file random.dat in the RAM Disk volume until it's filled to capacity.

This should artificially reduce your available RAM by ~2 GiB until you unmount the RAM Disk or restart your Mac.

After some testing this doesn't seem to work as reliably as in older system. The reason is the new memory management in the latest systems (10.9 and up).
The memory used by the RAM Disk shouldn't be swapped to disk but depending on the quality of the random data file it might be compressed a little bit. You may increase the RAM Disk size by 5-10% to ~2.1 GB to get a more realistic picture.


If you want to do this in 10.5-10.8 the following command seems sufficient to get a reliable result (to get the Disk Identifier check the output of the diskutil... command):

dd if=/dev/zero of=/dev/rdisk9 bs=1m
6
  • Cool solution! If I understand correctly I've commandeered 2 gigs of ram for a ram disk. That 2 gigs of RAM is allocated, but, since I'm not using the ram disk for anything, it's not actually being accessed by any processed. If I have virtual memory on, wouldn't the os write this unused block of ram to my swapfile, effectively freeing up the 2 gigs again?
    – dB'
    Apr 3, 2015 at 19:58
  • @dB' You are right with your first remark about unused RAM. In fact it will probably get highly compressed leaving a lot of free RAM. So i modified my answer to fill the disk with random data to bypass that.
    – klanomath
    Apr 3, 2015 at 21:05
  • You can probably just dump all the calculations of the disk size and let dd fill up the whole disk: dd if=/dev/random of=/Volumes/RAM\ Disk/random.dat bs=1024k
    – Josh
    Apr 4, 2015 at 20:55
  • @Josh I will try that again and modify my answer if it works. Yesterday i had problems executing the command in a VM. I just got a 'resource busy' error and nothing was written to the volume.
    – klanomath
    Apr 4, 2015 at 21:06
  • If you're writing to a file, of=/Volumes/RAM\ Disk/random.dat, then you should be fine. if you're writing to the disk, of=/dev/rdisk9, then you have to be root, and it may have to be unmounted. (it should be unmounted, otherwise the system will get confused)
    – Josh
    Apr 4, 2015 at 21:08
8

Yes - use the memory_pressure tool to apply real memory pressure to the system.

It's not a perfect analogy to removing the memory chip since the virtual memory tuning still knows there is 4 GB or RAM and the -p percent_free argument won't allocate a constant amount of RAM, but keep the system close to X percent free.

It should allow you to very quickly see if your workload is amenable to a system with 2 GB ram even with the imperfect analogy.

If you can physically remove the chip - you can first simulate things and get a benchmark and then do the hardware change if you need to verify it's accurate.

1
  • The main problem I see with removing the physical chip is that dual channel mode is removed from the picture, too. The first option in this answer seems like the better way to do it since the real performance issues simply come from the increased usage. Apr 3, 2015 at 20:59
5

Adding to OSdweeb's Answer:

Since El Capitan editing the com.apple.Boot.plist file is only possible when disabling the System Integrity Protocol (SIP) (see this thread).

You can, however, set the boot flags with the following command:

sudo nvram boot-args="maxmem=2048"

2

Another solution would be to use a virtual machine to simulate the lower-RAM Mac. Install VMWare Fusion, Parallels, or VirtualBox (if you're adventurous) and install OS X in that. Then you can manipulate the number of cores, amount of disk space, and (as you were requesting) amount of RAM available to OS X. VirtualBox is free, but currently limited to 3Gb for OS X until the developers allow 64-bit kernel operations. The other two products have 30-day and 14-day trials, respectively.

3
  • -1, sorry... this is not a good comparison. Now, you have virtualized video drivers, virtualized I/O, and a small CPU performance hit. I love Virtualization, but if all you want to do is see how the system would perform with less RAM available this is not a good solution.
    – Josh
    Apr 4, 2015 at 20:57
  • @Josh The small performance penalty for virtualization should be negligible: modern CPUs have hardware support for such a task, so the performance will be very close to bare-metal except for some esoteric fringe cases. Besides that, not only can you directly control how much memory is available, you can also adjust CPU frequency, available cores, video memory available, and other parameters. To truly simulate older machines, having these options available might prove useful. An OS's performance is more than just available RAM.
    – phyrfox
    Apr 5, 2015 at 9:09
  • If you're talking about enterprise grade virtualization like VMWare ESXi, then you're right @phyrfox -- about CPU speed. There is a performance hit on graphics and video processing which will be noticeable if running Mac OS X. I agree, Virtualization is the right solution when you want to adjust CPU frequency, available cores, hardware, etc. But this question was purely about limiting available RAM, and for that use case I believe that virtualization isn't the right solution.
    – Josh
    Apr 5, 2015 at 15:06
-1

To TAKE OUT RAM, you can:

If your macbook is Aluminium, you take the whole bottom off and the RAM should be right smack in the middle.

If it's white, take of the little compartment in the corner and access the ram that way.

Source: https://support.apple.com/en-ca/HT1651

4
  • 1
    Note that he asks to disable it without physically removing the ram.
    – Spotlight
    Apr 4, 2015 at 1:51
  • He could still solve his problem with this is what I meant...
    – Kachamenus
    Apr 4, 2015 at 20:46
  • 2
    But the question was, "Is there some way to temporarily disable RAM without physically removing the chip?", so this does not answer the question
    – Josh
    Apr 4, 2015 at 20:58
  • Sorry bout that. I was just stating there is a way to take out ram.
    – Kachamenus
    Apr 6, 2015 at 20:46

You must log in to answer this question.

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