Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have 6GB on my old Macbook, with an SSD. I would like to avoid writing to the swap file as much as possible. Ever since my upgrade, I have always had at least 1 to 1.5GB memory "free". Yet, I have always had 2 to 25MB of used swap space. (Out of 128MB total) How do I get this to be 0MB swap used unless I run out of "free" memory?

On Linux, there is now a "swappiness" parameter that controls the tendency to use swap. I'd like to crank OS X's "swappiness" down very very low, but not deactivate swap entirely. I'd like to know that my machine will just run slower if it ever runs out of memory instead of having a kernel panic. I'm pretty close to where I want to be, but I'd like to get rid of these writes to a large file that (slightly) shorten the life of my SSD while doing me no benefit whatsoever.

share|improve this question
    
It's understood you do what you want, and you're asking for an answer to this question — I won't contest this. However, I think it is important to make it clear for less technical-savvy users: the fact that your system is swapping, especially on such a little amount, is not a problem at all, not necessarily a source of sluggishness, and even the opposite. The OS can decide some memory parts won't be accessed and it's more effective to preemptively free some blocks in RAM and get extremely unlikely cache misses. OS X is very good at this (see RAM usage of hidden apps). –  MattiSG Nov 18 '11 at 15:33

2 Answers 2

I'm not sure that a swap file of 2MB to 25MB is really something to worry about. It might be more useful to look at the values for Page In and Page Out to determine how often data is being written to the swap. The number of page events can be found using the System Memory tab of the Activity Monitor application.

There are a couple of other options that you could try but I think you're probably way out of warranty if you try:

I would just suggest putting up with the existing system since the wear on your SSD is probably minimal especially since SSD wear is a bit of a myth anyway or maybe it's not.

share|improve this answer
    
Thanks, but if you re-read my question, you'll find that there are actually two files 64MB each. It's not just 2 to 25MB. It's 128MB total swap and 2 to 25MB usage. What I find annoying, is that the total swap varies between 64 and 128MB. This would seem to indicate that the 2nd swap file is being deactivated then recreated. That's a lot of disk use for nothing. I already knew of the two system mods you suggested, and indicated that I didn't like the 1st one. The 2nd one, I find to be not well engineered. –  StCredZero Feb 16 '11 at 23:19
    
This is your answer. Disabling the dynamic pager can really help but you truly run the risk of causing apps to go belly up when you run out of ram. If actually running out of memory isn't an issue for you then don't worry. –  Dustin Nov 18 '11 at 14:31

If there's anything like this available in OSX, it probably lives somewhere in here:

  sysctl -a | grep ^vm | sort

These look like possible suspects to me:

  vm.vm_page_free_target: 2000
  vm.memory_pressure: 0
  vm.page_free_wanted: 0

A HP doc on managing memory performance mentions some of those same kernel variables in S6.1.4 and S6.5. However, this looks like the golden egg in HP Tru64, and there's nothing like this I see in OSX:

  vm_aggressive_swap

Googling on vm_page_free_target turns up an OSX Internals book which might help.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.