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

Sep 13, 2013 11:49 AM in response to sergibondarenko

sergibondarenko wrote:


Please do not take offense, I have long understood that I need more RAM and SSD.

I just do not like the fact that the OS X 10.8 requires more memory than Windows 7/8 or Ubuntu 12 to solve same tasks. It's a kind of stupid.

I am currently running my data ingest testing on my 8 GB Core 2 Duo 2009 MacBook Pro running Mountain Lion. Normally I use one of my Linux servers that have from 8-64 cores and 32-252GB of RAM. However, I can't use the Linux servers this week because my development server keeps running out of RAM (it has 36 GB) mysteriously and causing Oracle connections to fail. They even rebooted it yesterday to try to clear it up and it is back to 0 GB free.


So don't tell me MacOS X has memory problems that Windows or Linux don't. I don't have memory problems like this on my Mac. Sure it would be faster if it had 32 times the number of cores and 30 times the RAM. Twice this year my Linux machines have been ususable for extended periods even with a full IT stuff and on-site support from Oracle. But it never locks up like Linux. It never has DLL conflicts like Linux. It never needs to be rebooted like Linux.

Sep 18, 2013 1:56 PM in response to etresoft

Got news for you. We run a simple Mac Mini server and was having MAJOR leakage...we only run about 2 -3 light apps. (Server, Dropbox and Dropcopy)


We upped our ram from 4GB to 16 GB.....so even still....after each reboot or purge....in about 10 minutes...the free RAM dwindles down to 18 mb.


So...what are you saying about leaks only happen with people who run Photoshop?

Sep 18, 2013 4:49 PM in response to K I M B A K A T

I didn't say anything about "leaks". I said that Photoshop users commonly report problems running with 4 GB of RAM in Lion and Mountain Lion and experienced no such problems in Snow Leopard.


You are running a server and complaining about free RAM. Lack of free RAM does not imply leaks. A server is much different and you don't want any free RAM on a server. A server is supposed to use all of its RAM so it doesn't have to go to disk to serve user requests.

Sep 19, 2013 11:04 AM in response to etresoft

So...we did a thunderbolt raid firmware update...when I rebooted from that update....the FREE RAM started dwindling down again and stopped at around 8GB Free. It stopped dropping and slowly bumped itself back up to 12 GB FREE on it's own. This happened over the span of 30 minutes after rebooting after that update.


I don't know if it was the firmware. There was just wonky stuff going on for a few weeks.

Oct 6, 2013 3:55 PM in response to imclerran

Whatever these cleverclots might say, the fact is I just installed Mountain Lion a few weeks ago and I have been having incredible problems with my Mac slowing down to a snails pace (as you say), I'm having to run memory clean and disk doctor approximately 3 or 4 times per 8 hour work session, just to get it running again. Like you I have 8 gbs of ram and I too noticed that when left inactive for any length of time the amount of memory I have available drops right down to just over a gig. This is crazy and I think your initial complaint is correct. MASSIVE MEMORY LEAKS - suffice to say, until apple stop behaving like EA games and get their house in order I WILL NOT BE BUYING THE NEW MacPro when it comes out.

Apr 3, 2014 1:21 PM in response to imclerran

Dunno if this helps, as a developer of Mac os x software, we have recently moved one of our code libraries from snow leopard to mountain lion and have seen free memory decreasing rapidly even though it is released correctly in the code. Code has been profiled a lot with xcode instruments and shows no leaks or increasing usage. Something in OS seems to of changed as we have the different machines running continously next to each other and snow leopard is releasing the memory we have released back to free, mountain lion does not.


Have no fix yet, apart from we will prob modify code to reuse a memory cache to reduce memory allocation/deallocations.

Apr 4, 2014 5:44 AM in response to imclerran

After much testing and benchmarking we have found the problem in our case and probably others as well. Unfortunately our fix is a developer fix not a user one.


We found that some Apple Objective C Class files that use the NSData class for reading files were the cause. The default NSData implementation now seems to cache a files data in memory when it didnt appear to in snow leopard. This cached data isnt released when we release memory obviously as its meant to speed reopening of the same file between app launches.


In testing opening and closing a lot of files after a purge, on 5 Mountain Lion machines we have out of 20 bench tested (same hardware, same software), these 5 would continually lose memory until it ran out. Inactive is never reused, and vital system services start to be killed off due to lack of memory. This can be seen in the logs (killed 9).


The solution for us is to use methods on these Apple classes that allow us to pass NSData objects into them as opposed to letting Apple create their own. The benefit of this is that by creating our own NSData object we have the option (NSDataReadingUncached) to configure it to not cache the files contents in memory. This has now fixed it for us and is backward compatible with snow leopard.


Apologies that this is not a user fixable solution, although 'purge' is a blunt global instrument for users to alleviate the problem for the time being.


Interestingly, Apple have redesigned the memory section of activity monitor to show File Cache as separate from other memory instantly showing the problem as it keeps growing without the change mentioned above. Would of saved us some troubleshooting time if we had tested on Mavericks first as the problem would of been more obvious, as we would not of gone down the path of "Memory Leak" profiling.


I can see why Apple say it works as it should as File Caching of recentl used files is obviously a feature, but the default change is probably going to catch a lot of developers out who use the default behaviour of some Objective C Classes.


See below for developer details:


https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation /Classes/NSData_Class/Reference/Reference.html#//apple_ref/c/tdef/NSDataReadingO ptions

Feb 11, 2015 1:39 PM in response to Linc Davis

No, that is not it. I'm loading audio samples and the amount used in this project is around 15GB. Under Snow Leopard, a certain amount, like 500MB or something of inactive would build up. Now it means that this 15 or so GB template is perilously close to maxing out my 24GB of memory.
You have an assumption behind some theory. "it means it is being used and released" No. It isn't. It's useless memory. In reality, this is a problem.
I'm probably going to have to give up whatever I'm using that requires 10.8 and go back to 10.6.8 if this can't be solved.

Feb 11, 2015 2:01 PM in response to etresoft

"but why are you blaming Apple" - why are you trying with all sorts of tactics to deny someone else's problem?
I know what was happening under Snow Leopard, and now I finally caved to ML and the amount of blue area in Activity Monitor's RAM display is dramatically more for exactly the same situation. I'm not doing one thing differently except for the change of OS.


The OS is NOT giving this RAM up with new loads; after a certain point the OS is beach ball o' doom all the time. So there is purge, which itself does not appear to work as well. But this is a real-life problem, sorry if that upsets you, identifying so strenuously with Apple as it appears here.

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.