Terminal 101: Managing Memory in Mountain Lion

Terminal 101: Managing Memory in Mountain Lion



Every Monday, we'll show you how to do something new and simple with Apple's built-in command line application. You don't need any fancy software, or a knowledge of coding to do any of these. All you need is a keyboard to type 'em out!

Keeping an eye on your Mac’s memory usage can bes vital for making your applications run faster and eliminate those that eat away at your virtual memory. You can do this right from within Terminal without any specialized apps using various commands.

Top

To view the amount of memory that you have free and are currently using, open the Terminal and type “top” followed by the enter key. This top command will return a few rows near the top of the Terminal window. Look for the “PhysMem” and “VM” rows.

In the “PhysMem” row, you can see how much memory is wired, active, inactive, used, and free. This is measured in gigabytes (“G”), megabytes (“M”), or kilobytes (“K”). PhysMem refers to the physical memory installed in your Machine; however, “VM” refers to the virtual memory that is allocated on your disk whenever your Mac runs out of physical memory. “VSIZE” indicates the amount of virtual memory OS X has assigned for processes or applications.

Once you are finished looking at the information provided by the top command, press the Q key to quit back to the command prompt.

Purge

While OS X has really good memory management, it’s not perfect. Sometimes RAM can be held in the “inactive” state, even when no longer needed. To free up some of your RAM for availability, try the “purge” command in the Terminal.

If you monitor your “Free,” “Used,” and “Inactive” memory stats before and after the purge, you will find dramatic changes. In addition to your physical memory, this command will also relieve disk and memory caches to be emptied. This command gives you the same benefits of rebooting, except your applications can stay running.

If you are a power user who uses applications that can occasionally hog disk and memory resources, then running this command can make your Mac feel more responsive.

Cory Bohon is a freelance technology writer, indie Mac and iOS developer, and amateur photographer. Follow this article's author, Cory Bohon on Twitter.



Read More

            Google+