Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Massive Mountain Lion memory leak

I will start describing the problem where I first discovered it.


My early 2011 MBP had been asleep, and upon opening and waking it, it was incredibly slow. I opened activity monitor and couldn't believe my eyes.


I have 8 GB of RAM, and all but 8 mb was in use. Around 6 GB was "inactive". I had no applications running besides Activity Monitor.


I opened terminal and ran the purge command After a short wait, total memory usage was back to around 2 GB. Then right before my eyes, over approximately 30 seconds, the "inactive" memory grew until once again, I had about 8 mb of RAM free. This fluctuated a few mb, but nothing significant.


After rebooting, I opened Activity monitor again, to watch ram usage. Usage increased to a little more than 2 GB. I then launched the App Store. Before putting my laptop to sleep earlier, I had been downloading a 10 GB update to Borderlands, but had paused the download, and quit the application before closing the laptop. I hit resume download, and went back to Activity Monitor. Memory usage seemed normal for several seconds, but shortly started increasing rapidly again. I imediately hit "pause download" in the App Store. But ram usage continued rising, so I quit the application. It kept rising, until my full 8 GB was in use.


At this point I took a screenshot:

User uploaded file


The only thing I have left to tell you is that before upgrading to ML, I had previously attempted to download the same update, but hadn't had time to download the full 10 GB, so had cancelled the update. That was in Lion 10.7.4, with 4 GB of RAM, and I had no issues.

MacBook Pro, OS X Mountain Lion (10.8.2)

Posted on Sep 26, 2012 6:17 PM

Reply
Question marked as Best reply

Posted on Sep 26, 2012 6:53 PM

Your screenshot shows nothing abnormal. Having a lot of inactive memory simply means that it's been used and released. If you're curious as to what was using it, you'll have to look at All Processes, not My Processes.

120 replies

Nov 10, 2012 3:22 PM in response to YagoDR

The only problem with asking for help by pigging backing on another user's thread, is you have no control of the thread. And if your discussion takes a "Left Turn", the original creator of the thread ends up having the discussion they started hijacked in a directory they may not like it to go (it could still go where they do not what, but at least it is about their problem, not someone else's 🙂 ).


But many people piggy back on existing threads. You are not the first, and will not be the last.


Do you know if purging the RAM when I feel the underperformance can be unhealthy for the system?

No. It just forces the system to invalidate its cached data. If any of the Inactive data was waiting to be written to disk, it is done at the time of the purge before being moved to the free list. Doing this every once in awhile is not much of an issue. Go ahead and purge away.

However, if you were doing a purge every few seconds, I would think you are making the problem worse, and putting an extra strain on your disk, as it will need to do more writes and a lot more reads as it will no longer have any data cached in RAM to avoid doing a read.


Sometimes I purge and a whole chunk frees up but in a matter of seconds the Inactive RAM builds up again, with no apps running and without quitting anything....just frees up and then drains down again

Then something is running that is using that data. TimeMachine, or another backup utility (Mozy, CrashPlan, Carbonite, SuperDuper, Carbon Copy Cloner, etc...), or iTunes downloading podcasts, or BitTorrent, your browser doing prefetches of pages it thinks you are about to read, or an RSS news reader checking for new stories and downloading them ever few minutes, you have enabled System Preferences -> Sharing -> File Sharing and someone else is read/writing files on your Mac, Software Update is automatically downloading the software updates before it tells you there is a new update, iTunes is downloading the next iPhone/iPad/iPod Touch update, you recently added new files, and Spotlight is busy scanning the data to update its Spotlight database, you installed a virus scanner and it is busy looking at all your files looing for non-existent virii, other app you have installed that runs in the background, or an Apple standard daemon I haven't thought of...


Inactive RAM is a cache of recently used data to avoid doing slow reads and writes to the disk. This is very important for battery life in a laptop as that disk drive is one of the more demanding power users on a laptop.


ve read about some scripts that'll purge the RAM if inactive memory build beyond a certain threshold or if Free Ram falls below a ertain threshold... any tips on that? Or is this behaviour perfectly normal in ML and I should simply forget about it? It's basically the fact that I have plenty of RAM but feel underperformance when I trust I shouldn't that bugs me

If you want to run a script, feel free, as long as it does not cause a purge constantly, as that would totally defeate the purpose of the cache, and if you have a laptop, drain your battery faster. If it only triggers a purge every once in awhile, again I do not see much of a problem.


However, the behavior of keeping Free RAM low and maximizing the cached data via Inactive RAM is normal behavior. After all you paid for all that RAM, when it is Free it is not doing anything for you. At least when it is Inactive it is potentially holding something useful, and attempting to earn its keep.


Another thought is maybe you are actually using your Mac, the apps you are running would benefit from more RAM, as I expect that you do not normally use your Mac with ONLY Finder and Activity Monitor running. If the apps you are using are RAM hungry, you might consider adding more RAM to your system. RAM is not very expensive these days. I just bumped my 27" iMac from 8GB to 16GB for $83 via Crucial.com. I'm considering doing the same thing to my Macbook Pro (I'm only holding back because the iMac just required removing 3 screws, and the Macbook Pro requires removing 10 screws and they are not all the same length (you have to keep track of which screw goes back into which hole 🙂 ).


If you are really have RAM issues when actually using your Apps, I find the best way to monitor that is by monitoring pageout numbers over time.


Start an Applications -> Utilities -> Terminal session and run the following command:


sar -g 60 100


which will tell you the number of pageouts every minute for 100 minutes (adjust the numbers to suit your tastes).


Now go use your Mac normally.


Come back after an hour, or when you feel performance is really back, and look at the pageout numbers. If mostly zero, then it is not paging and RAM is sufficient. If a few bursts of low values still not much of an issue. If sustained high numbers, then you either need to stop running so many concurrent apps, or get more RAM.

Nov 22, 2012 10:24 AM in response to imclerran

It's not so much the inactive memory thing, it's that the memory fills and the computers are paging to the hdd in the swap file. A friend is freaking out about his too. He has 6 GB of memory, 3.45 is inactive and the swap file is only 30 MB, this is after a reboot. Yesterday his inactive was around 2 GB & swap file was 3.61 GB. With that much memory, he should rarely use the swap file for what he does with it. And the fellow that has 20 GB of memory, for his system to have similar issues as a 6 or even an 8 GB system only on the magnitude of 2.5-3X because he hs 20 GB is unacceptable. These are not minimum systems, these are robust work stations that should handle these workloads and barely break a sweat, not even be breathing heavy.

Nov 26, 2012 1:54 PM in response to imclerran

I too am having a similar problem. I'm not a long-time MAC user, so I won't pretend to understand the intricacies, I'll just tell you what I've observed.


First off, I'm running Mac OS X Lion version 10.7.5 (11G63b), with a 2.33 GHz Intel Core 2 Duo processor, 3 GB 667 MHz DDR2 SDRAM, and 330GB of free disk space. An older MAC but running just fine prior to Lion.


Since installing Lion, on occasion, the system performance slows to a crawl. Up to a minute to switch between windows, for example. On opening Activity Monitor, in every instance of the performance slow-down, the free memory is around 10MB or less.


Shutting down various/all programs has no effect - free memory stays at bare minimum, and everything is painfully slow. Only a restart will bring the performance back to normal speeds. When performance is normal, free memory always shows in excess of 1GB.


There is one action I have been able to identify that will guarantee the system slowing to a crawl - and free memory dropping to <10MB : using Finder to search "all files". Searching a particular folder or drive won't cause it, only "all files". This is not the only trigger; sometimes the system will just bog down without Finder being in use, but I haven't been able to isolate any other common denominator.


To all those who trot out the meaning of free memory vs inactive vs wired and tell the many people who are experiencing this problem they just don't understand how it all works, I would say this: if there is a correlation between the amount of free memory and system performance, then it seems to me that's the place to start looking. No matter how it's supposed to work, this is the clue to the problem. And there is definitely a problem.


Prior to installing Lion, this did not ever happen. I'm including a screen shot of the Activity Monitor while the performance is crawling. You'll see Chrome running; this problem was happening before I installed Chrome - in fact I installed it to see if Safari was the problem.


I hope this will help with at least recognizing there is some kind of issue going on, as there seems to be an unwillingness to even acknowledge the possibility, based on the many threads I've read.

User uploaded file

Dec 13, 2012 9:52 AM in response to imclerran

Guys, something to digest here:


I have found another intersting issue in Mountain Lion that has also caused the memory consumption to leak or increase. When I switched from wireless connection to wired connection - with the wireless still on - my memory consumption was reduced by a factor of 1/3 its previous behavior. I can relate this to the fact that unless you are using an excellent router, which I don't have, your Mac will tend to store more information in memory as it keeps trying to get them over and over. But if you upgrade to a good router, you might solve the problem. I'm thinking about getting a Time Capsule for that.


I can also add up that I've been using lately the command "purge" from bash terminal to make sure the memory is clean and the performance was much better than before.

Dec 22, 2012 1:41 PM in response to ShyLion

I feel good to know I am not the only one with serious memory leaks. I have been trying to let my fellow mac users look out for this but for some reason I am the only one that notices.


It is not just a mountain lion issue as I have 5 Macs and while 3 have mountain lion, the other two have snow Leopard and still experience the memory leaks. And one of the machines is an iMac with 16GB of RAM. Plenty of headroom to run must of the apps I run.


What I have noticed is this - leave open a browser (with some multiple tabs open) - and walk away - and you will find some severe and crippling memory leaks. The culprits for me are two main URLs in general - facebook (a memory killer) and youtube. I figure the problem is with flash - just a guess.


Some browsers are worse than others - Chrome can kill memory quickly - so can Safari - but only depending on which URLs you have open. One of the better browsers I have found for general surfing is Stainless - it is a very basic browser that seems to handle memory leakage better than the rest. But as someone mentioned - I do have a few of the plugins running that are probably causing problems in the other browsers - such as fastest tube and adblock. Another plugin I recently found giving me a lot of grief was ghostery - for many reasons - so I had to disable that.


I am kind of a lazy mac user with some bad habits - mutilple tabs open on browsers etc. but until September was able to get away with that. Now - with recent changes to the OS - I cannot. I find this frustrating as the leaksage is so sever at a lot of times that it completey drains the machine of memory and I get crashes - browsers crashing out and systems halted unable to complete even the most simple of tasks - so I have to hard crash out and turn off the machine - sometimes I have even see it restart the machine without me even crashing out.


This thread has armed me with more ideas and things to try - and I will definitely be running Activity monitor to see where it is leaking from but for sure facebook and youtube are memory sucking culprits - anything that uses flash seems to drop the OS to its knees. I do believe that Apple has a real problem on its hands as this never happened before in either Snow Leopard or Lion (as I have been running both for many years) and it just happened in the last 4 months - so it was a change made to the OS.


What I would like to ask the more technical users is if there is a way to trap and sandbox tabs on a browswer and limit them to only a certain amount of memory and no more - at least it would stop my machine from crashing while my OS bleeds memory like a sieve. I do continue to use facebook and youtube but I am very careful to close them after use - but I am getting terribly frustrated at watching an iMac with 16GB RAM just leak away until total crash - that should not be happening - whether I had a few apps open or not. When the system is essentially idle - there should be a way to prevent excessive memory leakage for apps not being used - at least a way to trap the memory or cap at at a point not to go over to cause the OS to crash. I find that a failure in the way the OS has been written if it allows prcesses to hang the OS over and over again.


Any help would be appreciated.


Thanks.

Dec 26, 2012 5:21 PM in response to imclerran

I'm having a similar issue on 10.8.2, 2011 27" i7 iMac, 16GB of RAM.


Over time (like, two weeks), inactive memory fills up to take up all available free memory. This is my systems memory footprint running Safari (four tabs), Coda 2, Mail, iChat, Chrome and iTunes: all applications are up to date. These applications are the only ones I run almost all the time, with occasional Pixelmator and Photoshop instances.


This has only been happening since upgrading to 10.8.2 (from 10.8.1) so I'm convinced it's an OS issue, rather than an application issue.


The image below shows my memory footprint, and 7 day history. It's not the best example of it (it's been oddly stable this week, yet nothings changed) but it's the best I can do. I'd be interested to see if anyone has a fix, or knows the root cause of such behaviour, if you do, I'm all ears :-)

User uploaded file

Dec 26, 2012 5:29 PM in response to James G. Camp

James G. Camp wrote:


It's not so much the inactive memory thing, it's that the memory fills and the computers are paging to the hdd in the swap file. A friend is freaking out about his too. He has 6 GB of memory, 3.45 is inactive and the swap file is only 30 MB, this is after a reboot. Yesterday his inactive was around 2 GB & swap file was 3.61 GB. With that much memory, he should rarely use the swap file for what he does with it. And the fellow that has 20 GB of memory, for his system to have similar issues as a 6 or even an 8 GB system only on the magnitude of 2.5-3X because he hs 20 GB is unacceptable. These are not minimum systems, these are robust work stations that should handle these workloads and barely break a sweat, not even be breathing heavy.

The swap size doesn't tell much, what are important are the Page-Outs, anything above 0 means that the machine is paging to disk instead of using Ram. Low numbers don't matter much, what are yours?

Dec 27, 2012 1:08 PM in response to ShyLion

I don't think that the memory plot is giving us an actual indication for how the system behaves. I have seen something like that in Linux couple years back in RH. It looks like the system has swaped a lot of memory or locked a big portion but it is not. I have seen my iMac going into 99% memory usage with the inactive being 50% of my memory and the machine was still functioning okay. It might be little bit faster if not swapped like that.


Also, the key elements for such bad behavior are facebook & youtube & facebook & youtube.

Dec 27, 2012 6:16 PM in response to ShyLion

ShyLion wrote:


I don't think that the memory plot is giving us an actual indication for how the system behaves. I have seen something like that in Linux couple years back in RH. It looks like the system has swaped a lot of memory or locked a big portion but it is not. I have seen my iMac going into 99% memory usage with the inactive being 50% of my memory and the machine was still functioning okay. It might be little bit faster if not swapped like that.


If Page-Outs = 0 then no memory has been swapped. it is as simple as that.

Massive Mountain Lion memory leak

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.