When the wired and active RAM pass 50% - most tasks are measurably slower. You will see increased paging activity (vm_stat 15
in the terminal - watch for page outs - they indicate some memory had to be written to slow hard drive and constant page out and page in above 10-20 per minute indicates you have a RAM starved system.)
When starved for RAM, you can buy more or do less. You might want to get a monitoring software like Activity Monitor and keep the memory indicator in your dock. The system is likely thrashing based on the time delays you report. Each of the active programs needs some memory that just got paged to disk to free up extra space for memory needed by another program. It is a bad cycle and the computer just spends time running circles rather than getting done the work you wanted.
Here is a mac with every indication of RAM pressure:
But, quitting a large app like Aperture and starting it again still has no paging and the system is very responsive. Ignore the first line after the headings in vm_stat as it's the total since boot, but do watch for pageout as you have apps that are not responsive:
mac:~ me$ vm_stat 15
Mach Virtual Memory Statistics: (page size of 4096 bytes, cache hits 0%)
free active spec inactive wire faults copy 0fill reactive pageins pageout
260482 1186K 74303 275275 234520 323478K 2276158 188709K 120292 640158 482
260689 1187K 74303 275275 234038 4117 0 3256 0 0 0
261310 1185K 74001 275250 235835 10668 77 7115 0 4 0
292087 1153K 74711 274313 236770 32927 972 21684 0 18 0
521469 928347 75754 269861 235897 77208 130 63300 8 41 0
517897 936518 75766 269215 231981 27678 2504 13059 0 22 0
463894 987202 72076 274852 233371 126855 2712 89422 2 50 0
223701 1180K 77834 283568 265396 589512 255 562957 1 7278 0
205013 1186K 82765 291561 265293 389442 255 369664 0 7334 0
201401 1173K 89671 301672 265595 495426 82 472316 1 9286 0
However, starting about 4 of the Adobe CS4 apps can push this machine into thrashing and the slowness you describe with the apps taking 30 seconds to launch and lots of bouncing of square icons in the dock.
Here is the associated vm_stat 15
showing the problem. Look specifically at the free memory plummeting to the minimum and pagein / pageout climbing.
mac:~ me$ vm_stat 15
Mach Virtual Memory Statistics: (page size of 4096 bytes, cache hits 0%)
free active spec inactive wire faults copy 0fill reactive pageins pageout
21822 1190K 4746 585056 228411 332621K 2315577 196418K 121439 781551 1806
86862 1152K 5123 570803 215710 124555 932 102117 0 2086 15
73080 1161K 8631 571301 216607 24404 337 14931 0 1994 0
29655 1196K 13500 572024 219284 188966 535 112913 0 3606 0
1668 1208K 9616 594723 216954 174145 215 144996 16 15268 121
4142 1206K 5795 595393 219564 322750 0 320426 0 1 0
3043 1204K 3485 596990 223264 138981 136 136653 0 28 0
2338 1205K 2782 598556 222416 332263 321 321321 0 164 30
3251 1204K 2919 598770 222027 90135 82 85050 0 5 0
2606 1203K 212 600436 224678 114502 1 112450 0 35 0
1188 1200K 174 600230 228582 162660 117 157230 33127 860 9914
22069 1200K 27612 550547 230304 89953 38 82383 8274 159 2071
1910 1200K 349 600071 227976 24382 0 23465 7332 1 2985
1164 1201K 174 600281 228423 4940 1 4046 7087 8 2500
30404 1203K 186 567418 229475 16087 1 16045 8566 4 2235
I've been researching this very question for some time, and I've come to the conclusion that while there are several so-called "solutions" offered in various places, none of them really fixes the problem or makes the symptoms go away. The best I've found is techniques that change when inactive memory is swapped, such as the use of the purge
command you referred to. I believe that MacLemon is correct that swapping can be disabled only in entirety and not selectively, and so disabling the swapping of inactive memory would in practice be equivalent to disabling virtual memory altogether—which could be a workable solution on a machine with really large amounts of RAM, but is impractical on machines with a low maximum RAM capacity, such as MacBooks or Minis.
The reason that none of the ad-hoc purging solutions make the situation significantly better is that there are really only two ways to force OS X to clear inactive memory: the purge
command, or forcing allocation of all free memory (and since I'm not certain what method purge
uses, these two may actually be more or less the same). purge
, as you mentioned, takes a non-trivial amount of time to complete. Allocating all free memory simply accelerates the process by which the contents of inactive memory would be swapped out naturally, and so still takes up the same large amount of system resources. The only advantage of either of these solutions is that they allow you to choose when the swapping occurs, so it can be done before you would be normally trying to allocate that memory to something else. Whether that is actually useful to you depends on several factors, so the simplest way to find out is to just try it.
I've been testing a few of the memory-clearing utilities out there, and I've found that for me, manually forcing inactive swap requires more active monitoring of memory levels than is practical while I'm actually working, and using a utility that automatically forces the swap when free memory drops below a certain threshold is no better than letting the OS do it on its own, as I still have no control over when the swapping will occur and my apps will SPOD. So while there is an app that will do exactly what your alternative question asks for, that doesn't actually make the situation any less painful.
Until Apple's OS development team decides that the memory management system isn't working the way it's supposed to, and they figure out a way to make it work properly, the only real solution is to identify which apps are generating the most inactive memory and stop using them. In my situation, this has meant changing web browsers. I've been testing a variety of them, and Chrome is so far the one that seems to generate the least inactive memory, probably in part because every tab and every extension runs as a separate process, allowing the OS's native memory management to treat each one separately in terms of prioritizing swapping. Safari is the worst I've tried; starting with Safari 5.1, I could open a few tabs, do absolutely nothing, and watch the inactive memory rise rapidly in Activity Monitor—it would easily go from <1gb inactive to >3gb inactive within about five minutes, run the swap cycle, and then do the exact same thing. (Granted, memory that is doing nothing is exactly what makes it inactive in the first place, but it shouldn't create more inactive memory than was allocated active in the first place.) Safari 6 under Mountain Lion is a bit better, but not better enough to be worth switching back. Firefox, not being based on WebKit, ought to be better about this than either Safari or Chrome, but it has its own legacy of memory management problems, including a history of memory leaks, that make it no better in practice.
What would really fix the issue is if there was an option, likely a hidden option in the OS, telling the OS to simply dump the contents of inactive memory when needed instead of swapping its contents to disk. But I don't expect Apple to ever make such an option available.
Best Answer
Contrary to what you might think - macOS is actually not wasting RAM in this case.
As I see in your comments, you seem to be using an equation like this:
used ram = app memory + wired + cached
and you're using the term "used ram" as if it means "spent ram" or something like that.
That's actually not the case.
If you want to look at "spent ram" (i.e. RAM used for something that cannot currently be used for something else) you should not include the cached RAM in the equation!
What you really want to have happen is for as much RAM as possible to be used as cache RAM. It will potentially speed up future data requests as they could potentially be fulfilled from cached instead of from the much slower disk - all while not taking up any valuable resource at all, because as soon as that RAM is needed for something else, the operating system will just use it for that something else.
The other part of your question is wanting to manage launch agents and daemons in order to be able to enable/disable them according to your needs from a big list. You can do this with the tool LaunchControl available from here:
https://www.soma-zone.com/LaunchControl/