0

I have an 8GB RAM MacBook Pro that struggles under my workload and I regularly have yellow memory pressure. I do notice that during these times, the disk caching (i.e. 'Cached Files') is taking up ~1GB of RAM. Though I am well aware that files in RAM is much faster than if it has to pull it off the disk, the machine DOES have a pretty fast SSD and I'd be willing to have less disk cache in favor of more application RAM.

Is there a way to set the amount of memory (or behavior rules) around how the OS utilizes disk caching? I'm a bit surprised that when memory pressure gets bad, it still insists on using a good chunk of my RAM to cache instead of at least cutting that in half.

3
  • 1
    macOS - arguably - does a pretty good job of RAM handling. I remember editing light 4K videos in FCPX on my MBA 2013 13" with 4GB RAM. I highly doubt you could manually increase the speed. Apart from that, I don't think you can control that.
    – X_841
    Commented Feb 3, 2021 at 15:08
  • 1
    When you're getting the yellow memory pressure, what's the value for swap? That's more likely to be slowing you down, especially if you're switching between apps.
    – Tetsujin
    Commented Feb 3, 2021 at 15:13
  • I always have swap and compressed memory in my typical scenario. Right now things feel to be working well enough and I've got 2GB of swap and 1GB of compressed registered. If this was a HDD, I'd take swap usage far more urgently; yes, swap is always slow but it does help that the internal SSD is extremely fast. That being said, that is less the focus on the question.
    – bjb
    Commented Feb 3, 2021 at 17:57

1 Answer 1

2

Yellow memory pressure is not in itself an indication of any sort of "problem" with your system.

If that is the only "negative" indication in Activity Monitor, then getting rid of cached files from memory won't help performance of your system. Rather the opposite.

Take a look at "Swap used" in Activity Monitor - if this is "0 bytes", then the system has the RAM it needs, and getting rid of cached files won't mean that the now freed memory can be used for something that would somehow speed up your system.

However, if your "Swap used" is a significant amount, it might be that getting rid of cached files could speed up your system. It doesn't mean that in every case though. What matters is whether the swapped out data is something the system actually needs now. If that is the case, you can check the amount of data swapped in/out per second (or minute or similar) to see if the system is actively swapping in/out data while you are experiencing problems with your workload.

If you do indeed convince yourself that changing the disk caching behavior is necessary, you can use the sysctl command in the Terminal to do so.

You can list all the possible settings using sysctl -a - especially the ones that have "vm" in the name are be interesting here. I would take a look at the following settings:

  kern.vm_page_free_min
  kern.vm_page_free_target
  kern.vm_page_free_reserved
  kern.vm_page_speculative_percentage
  vm.vm_page_background_mode
  vm.vm_page_background_target

You can see their current setting like this:

sysctl kern.vm_page_free_min

And set a new value with:

sysctl kern.vm_page_free_min=250000

Note that the above is just a fictive example - you would need to supply your own value.

1
  • Thanks, will look for docs on these values and experiment a bit.
    – bjb
    Commented Feb 3, 2021 at 17:59

You must log in to answer this question.

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