When you run programs and do other activities on your computer, content of different sorts gets loaded into the RAM and disk caches, and when you quit a running program, all that loaded content should be purged from memory.
Mac OS X has fairly good memory management but it’s not perfect, and sometimes RAM can be held unnecessarily in the “inactive” state despite the contents no longer being needed.
But you can force your Mac to clear out the RAM and disk caches without rebooting and you can maintain currently active applications while still freeing up memory.
Launch Terminal, found in /Applications/Utilities/ and enter the following command sudo purge
Now, just type in sudo purge inside the Terminal window and hit Enter. This will begin the process of clearing your RAM and disk cache contents.
You will get a prompt asking you to type in your password. In OS X 10.9 or higher, this command requires an administrator password, hence the use of sudo.
Go ahead and type your password in—Terminal won’t show your password for security reasons. When you’re done, hit Enter again.
The purge command forces disk and memory caches to be emptied, offering a ‘cold disk buffer cache’ which is similar to the state of the operating system after a reboot.
This is not necessary for most Mac users, but power users and those with heavy memory demands will undoubtedly find this command helpful in the future.
Also Read -> How to Frees Up Lots of Storage Space on Your iPhone