Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

madoka

macrumors 6502a
Original poster
Jul 17, 2002
526
153
Why is my Macbook Pro 16 with 32gigs of RAM keep using disc swap when there's 10gigs of RAM free? Isn't this wearing out the SSD unnecessarily?

Screen Shot 2023-03-02 at 7.10.10 AM.png
 
  • Haha
Reactions: PauloSera

russell_314

macrumors 604
Feb 10, 2019
6,659
10,260
USA
Why is my Macbook Pro 16 with 32gigs of RAM keep using disc swap when there's 10gigs of RAM free? Isn't this wearing out the SSD unnecessarily?

View attachment 2167157
It is normal. The same thing happened with my Mac mini that had 32 GB of RAM. Even Windows PC's do it. As to the technical details IDK but I suspect the programmers at Apple know more than me so I leave it alone.

Here is another thread with lots of replies so it might be helpful.

 
  • Like
Reactions: compwiz1202

leman

macrumors Core
Oct 14, 2008
19,520
19,671
Why is my Macbook Pro 16 with 32gigs of RAM keep using disc swap when there's 10gigs of RAM free?

Virtual memory management is an extremely complicated topic. There can be many good reasons for parking inactive memory pages on disk.

Isn't this wearing out the SSD unnecessarily?

Sure, average swap usage might lower your expected SSD life by a day or two… is it really something to worry about though?
 

Juicy Box

macrumors 604
Sep 23, 2014
7,580
8,920
I don’t know for sure, but I always thought it had to do with data that hasn’t been used in a very long time, the OS figures he can store it and swap because it hasn’t been used in a while, so freeing up RAM that could be used more quickly if it didn’t have to swap first.

I don’t know if it will work with Apple Silicon Mac, but there used to be a terminal command to disable virtual memory.

I used the terminal command to disable virtual memory on my old Mac Pro in the past, I think it was before TRIM support was added to MacOS.

By the way, I am not recommending you to do this or saying this is a good solution for you, but if it really bothers you, maybe it’s worth looking into.
 

MacCheetah3

macrumors 68020
Nov 14, 2003
2,285
1,219
Central MN
Why is my Macbook Pro 16 with 32gigs of RAM keep using disc swap when there's 10gigs of RAM free? Isn't this wearing out the SSD unnecessarily?

View attachment 2167157
Probably a brief spike in demand.

And:
60 MB is also an extremely tiny amount.

but if it really bothers you
Restart your Mac. From what I’ve observed (including other posts), macOS only feels the need clean/purge VM page files at (re)boot. Perhaps it’s a behavior originating from UNIX. In other words, whatever amount is shown in Activity Monitor isn’t necessarily still being swapped around on disk — it may have even been just a one time swap days or weeks ago, depending on how often you restart your device.
 

pdoherty

macrumors 65816
Dec 30, 2014
1,491
1,736
Why is my Macbook Pro 16 with 32gigs of RAM keep using disc swap when there's 10gigs of RAM free? Isn't this wearing out the SSD unnecessarily?

View attachment 2167157
Not only is it putting unnecessary wear on the SSD it’s also slow and inefficient in general since RAM is far faster. Mac OS (and Windows) are both terrible about this, using swap all of the time even when there’s plenty of RAM. Linux doesn’t do this and will leave swap at 0 until/unless there’s actual need, which is what all OSes should do.
 

Juicy Box

macrumors 604
Sep 23, 2014
7,580
8,920
Not only is it putting unnecessary wear on the SSD it’s also slow and inefficient in general since RAM is far faster. Mac OS (and Windows) are both terrible about this, using swap all of the time even when there’s plenty of RAM. Linux doesn’t do this and will leave swap at 0 until/unless there’s actual need, which is what all OSes should do.
While not the same thing as how it is used in Linux, virtual memory can be disabled on MacOS if someone was worried about SSD wear.

In very old MacOS versions, there used to be GUI to disable/enable it, and how much to reserve for it, but I think that went away with OSX.

It can still be disabled using terminal, but I haven't tried it in AS.
 

Sydde

macrumors 68030
Aug 17, 2009
2,563
7,061
IOKWARDI
It is possible that part of the swap is data that is already likely to be written to storage, so that saving files might become as simple as reallocating te swap sectors over to the file the belong to. As a Unix, macOS creates a lot of log files, so it would make sense to swap out those pages that are storage-destined to begin with.
 
  • Like
Reactions: AlixSPQR and leman

ignatius345

macrumors 604
Aug 20, 2015
7,614
13,025
While not the same thing as how it is used in Linux, virtual memory can be disabled on MacOS if someone was worried about SSD wear.

In very old MacOS versions, there used to be GUI to disable/enable it, and how much to reserve for it, but I think that went away with OSX.

It can still be disabled using terminal, but I haven't tried it in AS.
I'm curious: what happens if you run out of RAM and you have swap disabled?
 

Juicy Box

macrumors 604
Sep 23, 2014
7,580
8,920
I'm curious: what happens if you run out of RAM and you have swap disabled?
It has been a while, but IIRC what happens is the OS will crash, and require a restart.

IIRC, I only had it happen to me once. At the time, I was using a Mac Pro 1,1 with an SSD as a boot drive and 11GBs of RAM. This was prior to TRIM support.

I was testing the limits of my 11GBs, as MacOS tend to start using swap way before you actually needed it, so I never knew what the limits were.

I don't remember exactly what happen, or if there was an error screen that popped up, or if it just froze, but I am pretty sure it just required a restart to fix.

11GBs was a decent amount of RAM back then, so I really didn't have that much worry. I might have used a free memory app as well, but it has been while, and I cannot remember what the name was.
 
  • Wow
Reactions: ignatius345

pshufd

macrumors G4
Oct 24, 2013
10,146
14,572
New Hampshire
Activity Monitor only shows you the current swap. It doesn't show you the rate of swap activity. So if you start up a program and you don't use it for a year, then it shows the swap for the program. But it actually doesn't contribute to SSD writes.
 

Basic75

macrumors 68020
May 17, 2011
2,101
2,447
Europe
Activity Monitor only shows you the current swap. It doesn't show you the rate of swap activity. So if you start up a program and you don't use it for a year, then it shows the swap for the program. But it actually doesn't contribute to SSD writes.
Agree. I'm quite paranoid about SSD wear and senseless paging or swapping, but even I wouldn't be worried about 60MB of used swap space just sitting there.

To see the swapping activity I would recommend running the command "vm_stat 1" in Terminal.app (you might want to consult the man page via "man vm_stat" to make sense of all the numbers).
 

unrigestered

Suspended
Jun 17, 2022
879
840
yup, it's just the current size of the cache that's been moved onto your SSD.
it doesn't mean that these 60MB (in this case, might be 20 or more GB for others) will be overwritten constantly to your hard drive. they're just sitting there, like an app or a file that you've installed.
if you are frequently downloading large files like videos, you probably put some 10000% more strain to your drive than swap usually would / could.
of course one should avoid always being in the reds (or amber) when possible / applicable, but i think this "issue" is way overblown

of course working with large! video projects, etc might give you some huge swaps too, but that will sooner or later happen on most other systems, even with huge amounts of RAM too if the video files are just large enough (8k Hollywood quality 2h movie projects)

so in short: if you are truly worried about your SSD life, best advice would be to stop using your computer for anything that's doing more than just reads to your drive, so don't download and/or install anything (no macOS updates either, those are huge!)

your Mac will thank you with incredible life times 🤓

(and don't forget about all those several thousands of parameters per minute macOS is writing to your SSD anyway! 😜)
 
  • Like
Reactions: Analog Kid

ignatius345

macrumors 604
Aug 20, 2015
7,614
13,025
It has been a while, but IIRC what happens is the OS will crash, and require a restart.

IIRC, I only had it happen to me once. At the time, I was using a Mac Pro 1,1 with an SSD as a boot drive and 11GBs of RAM. This was prior to TRIM support.

I was testing the limits of my 11GBs, as MacOS tend to start using swap way before you actually needed it, so I never knew what the limits were.

I don't remember exactly what happen, or if there was an error screen that popped up, or if it just froze, but I am pretty sure it just required a restart to fix.

11GBs was a decent amount of RAM back then, so I really didn't have that much worry. I might have used a free memory app as well, but it has been while, and I cannot remember what the name was.
Interesting experiment, but I sure wouldn't want to work that way day to day!
 

dgdosen

macrumors 68030
Dec 13, 2003
2,817
1,463
Seattle
If memory on an Apple Silicon device has a bandwidth of 400GB/s and BlackMagic Speed Test shows SSD read/write speeds of ~5,000MB/s - is that saying:
- That using a swap file has a ~80x performance hit compared to memory? (400GB/s / 5000MB/s)
- That 32GB of memory could be completely re-written ~12x per second? (400GB/s / 32GB)

Or is that a bad way to look at it, because memory/swap file access is not a clear picture of overall system performance?
 

name99

macrumors 68020
Jun 21, 2004
2,410
2,310
Why is my Macbook Pro 16 with 32gigs of RAM keep using disc swap when there's 10gigs of RAM free? Isn't this wearing out the SSD unnecessarily?

View attachment 2167157
You're not seeing lots of paging, you're seeing the existence of a small stub VM file ready to be expanded when necessary.
The baseline macOS does not provide any tools that show levels of paging. The easiest way to see this is to install iStat Menus and look at the Memory menu which will show two items, page-ins per second and page-outs per second. Page-ins per second are no big deal, they are the normal way non-modifiable pages (like program instructions and read-only resources) are read from disk. It is only if you have a non-zero page-outs per second value that you are actually paging.
MacOS just does not page-out unless things are really grim. Right now my 32GB machine has about 47GB of virtual address space allocated (40GB of it in Safari because I have a HUGE number of windows open), my swap file is 16GB in size, but there is zero paging going on. Very occasionally a page will be written out, but chances you get to see this happening are very low, it's just not that common.

As for "wearing out the SSD unnecessarily", give it a rest; just give it a rest.
Just remember that the exact same people who are utterly clueless about every other aspect of a modern mac (VM design, CPU design, OS design) are just as absolutely clueless about the realities of SSD's...

Screenshot 2023-03-03 at 10.54.18 AM.png
 

Analog Kid

macrumors G3
Mar 4, 2003
9,360
12,603
If memory on an Apple Silicon device has a bandwidth of 400GB/s and BlackMagic Speed Test shows SSD read/write speeds of ~5,000MB/s - is that saying:
- That using a swap file has a ~80x performance hit compared to memory? (400GB/s / 5000MB/s)
- That 32GB of memory could be completely re-written ~12x per second? (400GB/s / 32GB)

Or is that a bad way to look at it, because memory/swap file access is not a clear picture of overall system performance?

It's a simplification, but it's not a bad way to look at it.

I'm not sure what you're rewriting the the 32GB from, but if you're talking about reading it from disk then you'd use the 5GB number but probably double the read rate because memory gets compressed before it gets paged out. So about 3 sec to completely fill memory from SSD and less than a 10th of a second to read in a few hundred MB for a document that got paged out.

For applications that aren't document based but need to hold a large dataset in memory, the numbers start to break down. If you're doing analysis on a 40GB dataset, you can't hold it all in memory so if you need to access part of it that is in swap you'd read in 16kB at a time (which is not going to be at the 5000MB/s rate, that's for big transfers), and write something else out to make room. If what you want is never in memory then the system can spend a lot of time on I/O. This isn't a problem when the limiting factor is a human's ability to click and scroll.
 

ChrisA

macrumors G5
Jan 5, 2006
12,917
2,169
Redondo Beach, California
Why is my Macbook Pro 16 with 32gigs of RAM keep using disc swap when there's 10gigs of RAM free? Isn't this wearing out the SSD unnecessarily?

View attachment 2167157
I don't see 10 GB of free space I see that 21.13 + 9.97 = 31.1 GB is beibg used. So you have 0.9 GB free.

It is the operating system's job to always put all available RAM is use. RAM nt used for apps is usually used to cache files. The system is faster, overall, if it places some data n swap so as to allow a larger file cache.

If you are worried about SSD wear-down then a larger file cache is the best this you can have. That swapped dat might never be read but you active file? it knows for sure those are active.

Again the OS' job is to use RAM as effectively as possible. Finding stuff that can be swapped out is part of that process
 

Ethosik

Contributor
Oct 21, 2009
8,142
7,120
If you want to skip the technical jargon:

Not entirely true. I ran into a couple of bugs with Davinci Resolve that caused red memory pressure for a basic 1080p video. Something that Final Cut Pro can use in 5 GB. And this is on my 128 GB RAM Mac Studio.
 

Fishrrman

macrumors Penryn
Feb 20, 2009
29,238
13,307
I've said it before and I'll repeat:
The OP's complaint is one of the reasons I've turned OFF VM disk swapping on my Macs (using terminal).
Open Activity Monitor, and all I'll ever see is:
Screen Shot1.jpg

If I enter this in terminal (to check swap):
sysctl vm.swapusage

Terminal gives me this reply:
vm.swapusage: total = 0.00M used = 0.00M free = 0.00M

VM -- it's something I neither need nor use!
 

MacCheetah3

macrumors 68020
Nov 14, 2003
2,285
1,219
Central MN
Not entirely true. I ran into a couple of bugs with Davinci Resolve that caused red memory pressure for a basic 1080p video. Something that Final Cut Pro can use in 5 GB. And this is on my 128 GB RAM Mac Studio.
I get your point, and troubleshooting is valid. However, that does not nullify the Apple support/KB document, which does not address — no pun intended — the RAM usage cause/source. In other words, your scenario would err could still befit from more RAM as the article indicates, but with an indefinite ceiling.

I've said it before and I'll repeat:
The OP's complaint is one of the reasons I've turned OFF VM disk swapping on my Macs (using terminal).
Open Activity Monitor, and all I'll ever see is:
View attachment 2170326
If I enter this in terminal (to check swap):
sysctl vm.swapusage

Terminal gives me this reply:
vm.swapusage: total = 0.00M used = 0.00M free = 0.00M

VM -- it's something I neither need nor use!
So does mine, and I’ve had dozens of Web browser tabs across Chrome and Safari*, an image in Affinity Photo, Mail and Messages constantly open, TechTool Monitor service (in the background), YouTube playing in Chrome, Activity Monitor, and still have enough RAM for 5GB+ of cache. Of course, memory pressure is green.

* I don’t use ad blockers or lots of Chrome err Web browser extensions

P.S. From my observations — yes, only one perspective — 12GB would be a solid base RAM amount.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.