If you don’t want any of the bells and whistle’s that come with Memory Clean, you can create your own application that cleans the memory with only a few lines of (easy) code.

Start by opening Terminal.

  1. Enter the following line:
    cd Desktop/

    and press enter. This points the Terminal to your desktop rather than your user folder. You can point Terminal to any folder you want for this tutorial.

  2. Enter:
    touch Purge

    and press enter. This creates a new file called “Purge” on your desktop, you won’t see it just yet though.

  3. Enter:
    pico Purge

    and press enter. This opens up the Terminal editor for the purge file.

  4. Enter the following text in the editor:
    #!/bin/sh
    purge

    The #!/bin/sh command tells your computer that this is a terminal script, and the purge command tells the computer to purge or clean the memory.

  5. Press Control + O and then Enter to save the file to your desktop. Then press Control + X to exit the editor. Make sure to use the Control key, not the command key.
  6. Once you’re back at the normal Terminal screen, enter:
    chmod 755 Purge

    and press enter. This makes the file we just created accessible to you. By default, OS X hides the files you create using touch.

  7. You now will have a file on your desktop called “Purge.” You can open this file to automatically clean your computers memory. Once the Terminal shows a [Process complete] message you can close the application and continue on.

Thanks to tutsplus.com for this great tips.