Thursday, December 31, 2009

Macbook Memory and Swap files tip

If you are like me, meaning (in this special case):
  • don't like to reboot your Macbook and have it running for weeks,
  • from time to time have some heavy computing sessions with dozens of progs running,
  • realising, that OS X Snow Leopard still does not manage its memory efficiently, by for example releasing the many and huge swap files created for these heavy computing sessions after these programs have been closed, even so your memory monitor shows you, that you have plenty of free RAM left
  • and you still don't want to reboot to remedy this problem (= OSX still using the swap files, even so it has free RAM).
you could try the following in a Terminal (found here: Link, but I save you from reading all that.. ;) )
  • sudo purge
  • sudo killall -HUP dynamic_pager
From the manpage of purge:
Purge can be used to approximate initial boot conditions with a cold disk buffer
cache for performance analysis. It does not affect anonymous memory that has been
allocated through malloc, vm_allocate, etc.

dynamic_pager is the prog responsible for the swap files on the Mac. This command is what you could call a 'friendly' kill, because it asks to 'HangUP' on the program, not just to terminate it.
I have tried it and so far it looks very efficient, and saved me already 1 or 2 reboots after only 1 day (of heavy computing.. ;)

Enjoy and Happy New Year to all my 2.3 readers.. ;)

2 comments:

  1. i like it :-) it likely what the shareware app "iFreemem" does albeit it doesnt fix/flush the swap afterwards .. i would love to have somethink like swapoff/swapon in mac like under linux .. tnx

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete