I use mysql and it takes up to 2.5 GB of my ram. I checked activity monitor and saw that I have 1GB of inactive memory but it never changes even if I have only 10MB active free memory. Is there any way to force the inactive memory to be used?
2 Answers
You can think of inactive memory like free memory that's been reserved for a recently closed application, but ready to be consumed by other uses when the 'truly' free memory has been exhausted. If you have 1 GB of memory (for the sake of making this discussion easier) on a freshly booted system, imagine the OS uses 300 MB and you open an app that uses 200 MB. You now have a total of 500 MB used, and 500 free. If you close that app that was using 200 MB, the memory is marked inactive and you'll now have 300 used (OS), 200 inactive, and 500 free. If you open an app that requires 600 MB, it'll use the free memory then pull from the inactive pool.
You can free inactive memory by opening Terminal.app and typing (without the $):
$ purge
You can, also configure MySQL to use more memory but if you're not having performance problems I'd leave everything alone:
- http://dev.mysql.com/doc/refman/5.0/en/innodb-configuration.html
- http://dev.mysql.com/doc/refman/5.0/en/memory-use.html
For more information on inactive memory in OS X:

- 235,889

- 3,702
- 23
- 22
To expand Aaron's answer:
Your case could be a problem with MySQL taking too much resources, but Inactive Memory is like Free Memory for the Operating System. The difference between Inactive and Free is that Inactive was recently used, so if you for example open iTunes and it uses 200MB, when you close it, the program gets closed, the memory of iTunes marked as Inactive but it remains like that unless its needed again. But if you happen to re-open iTunes, OS X knows that it's there already and inactive, so it marks it as active again and voilá, that was faster than having to reload it from the slower hard drive.
Provide more information about your computer to help find the cause of your "slow" system.
update: Here's more info about Memory and OS X (from Apple):

- 17,704

- 21,864
-
for example I have this in my activity monitor : mysqld -> 2.2 GB oovoo -> 190 MB kernel -> 150 MB firefox -> 148 MB and other apps. I have 26MB free memory and 1GB inactive memory and my system is a little slow right now but my inactive memory does not change. – AliBZ Mar 17 '11 at 20:32
-
1@AliBZ: Is the "Swap outs" count in Activity Monitor climbing? That's the best indicator I know of that the system is really out of useable RAM (and having to swap memory contents out to disk to make room). Note that "Page ins" are not a useful indicator, as they'll climb every time a program is launched from disk (unless it happens to be already in inactive RAM). – Gordon Davisson Mar 17 '11 at 23:51
purge
freezes my system for a few second and does ... nothing at all (at least with respect to the inactive memory pb). And yes, my system is swapping too even though I should have more than 1GB of RAM free. – PierreBdR Mar 24 '12 at 15:07purge
is exactly expected - you told the kernel to flush all of the inactive pages Right Now, so it stopped the world and examined all of them -- writing any buffered output to disk, putting the pages back on the free list, etc. But if your system is swapping, the inactive list is going to immediately grow again as the system (again stops the world &) brings those now-flushed-but-previously-cached virtual memory pages back in from disk (and puts to-be-paged-out ones on the inactive list). – jhfrontz Jun 25 '14 at 01:01