15

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 2

18

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:

For more information on inactive memory in OS X:

23
  • 1
    @PierreBdR What's the basis for your assertion? Have you used a kernel debugger and actually tracked a candidate physical page on the inactive list and watched as an [otherwise still] active page was [not put on the inactive list but ] paged directly out with another virtual page taking the newly freed physical page? Have you looked at the kernel memory management code and found a bug?
    – jhfrontz
    Commented Jul 1, 2014 at 22:59
  • 1
    @PierreBdR that doesn't prove your point. There are many other variables to the experiment that you're not controlling for (e.g., concurrent open applications/files, history of applications/files/work done since boot time, etc.). In your experiment, you'd need to know exactly what is on the "inactive list" and how dynamic it is with respect to the EXACT ADDRESS & CONTENT OF PAGES PRESENT, not the count of pages; the count of pages (which as you saw -- and as I would expect) remain fairly constant unless you change the active applications/workload, kernel tune/watermark-threshold values, etc.
    – jhfrontz
    Commented Jul 10, 2014 at 14:53
  • 1
    @PierreBdR the only "reports" I've ever seen are from people who don't understand how virtual memory works. See apple.stackexchange.com/a/67048/10389 for an excellent discussion by bmike.
    – jhfrontz
    Commented Jul 11, 2014 at 16:10
  • 1
    @PierreBdR You continue to make assertions without giving any definitive proof/citations. I again refer you to apple.stackexchange.com/a/67048/10389 and invite you to share how you know otherwise.
    – jhfrontz
    Commented Jul 14, 2014 at 14:01
  • 1
    @PierreBdR That people do ridiculous things doesn't mean they're well-reasoned (look up "Cargo cult science"). And I again ask: how do you KNOW that it wasn't pulling pages from the inactive list? Just because the count remained the same doesn't mean that it wasn't pulling them off-- instead, it means that they were being put on as fast as they were taken off (i.e., you have insufficient physical memory). I again invite you to read this and actually learn how VM works: developer.apple.com/library/mac/documentation/Performance/…
    – jhfrontz
    Commented Jul 14, 2014 at 21:37
0

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):

http://support.apple.com/kb/ht1342

2
  • 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
    Commented Mar 17, 2011 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). Commented Mar 17, 2011 at 23:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .