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

Memory leaks in Lion?

I have a 2008 21-inch iMac, and a 2010 MacBook Pro, both with 4 GB RAM, running OS X Lion 10.7.3. Ever since I installed Lion, I've had this problem of available memory dwindling to almost nothing (10-20 MB) after a day or so of usage. Last night I went to bed and the MacBook Pro had 400 MB available (according to Activity Monitor) and when I woke up this morning it was nearly frozen with only 10 MB available.


I'm not an extreme techie but I've been working in the IT world for over 30 years, including 3 years with Apple, and in my experience this situation is called a Memory Leak. If it were just one of my systems I would suspect something local, but they both behave the same way. (My partner's machine does the same thing.) I've installed the 3rd-party app Memory Freer, which frees up 6-800 GB each time I run it. But as time goes on the memory fills back up again more quickly, and finally I have to reboot.


Checking Activity Monitor, it's not just one app that takes up memory - they all seem to grow over time. (Mail, iPhoto, iTunes, Word, Chrome, etc.) Chrome seems to be the worst offender, with a plethora of Worker and Renderer processes grabbing 10-80 MBs for each open window - and I often leave 10-15 open at any given time. But all apps' memory usage grows over time, even if I haven't accessed them - witness last night's spontaneous bloat on my MacBook.


I've read a couple of other threads on Memory Leaks, but most point to a single app or just suggest Memory Freer. Does Apple know it's got a major league problem here? Are they doing anything about it?


One other point - I get the spinning ball on a lot of tasks, most often with Word and and Excel re-calc, which can last 3-5 seconds, and is another indicator of system overload, even when I've cleared the memory with MemoryFreer and there is supposedly several hundred GB of RAM available. This issue lessens after reboot, but is almost constant with Microsoft Office apps.

iMac, Mac OS X (10.7.3), 4 GB RAM

Posted on May 31, 2012 4:15 AM

Reply
21 replies

May 31, 2012 5:42 AM in response to LKHill

It's not likely to be a memory leak in the system. I almost never restart (generally only after an update or install that requires it), and I never quit Mail or Safari except when necessary, and don't see similar behavior. (I will admit that I haven't tracked the memory used by those apps over time, but I don't have the performance problems either.) Many of the other experts on these forums that I have talked to about this do similar things without issue.


Note that free memory is not necessarily a desirable thing... the OS should, when working properly, free inactive RAM as needed. Since inactive RAM basically amounts to application data cached in RAM, it can help keep your system running faster by keeping it around.


All that said, obviously you have a problem. Where it might be is a very complex issue. My first thought would be that you may have some third-party software that is causing problems. Try running the following command in the Terminal and let us know what the output is:


kextstat | grep -v com.apple


That will list any third-party kernel extensions that are installed, which does not by any means identify all third-party software installed, but I'd guess a kernel extension would be most likely to cause problems.


If that line of investigation doesn't lead anywhere, you ought to try some of the tips found in the Mac OS X Speed FAQ.

May 31, 2012 6:12 AM in response to LKHill

I have experienced similar problems in the recent past (Safari, and "Safari Web Content" processes being two of the most egregious memory hogs). Also, often the system did not properly return Inactive Memory to Free, when free memory was too low.


I am pleased to report that after updating Lion to 10.7.4 memory usage has been much more adequate.

Updated Safari to 5.1.7 at the same time.


I suggest you try the update.

May 31, 2012 7:52 AM in response to LKHill

Lion introduced a new process model. Just about everything you ever start never really exits -- processes never really terminate -- but are instead sent into a sleeping state. (There is a more accurate explanation available around here somewhere -- maybe in the developer forums -- but I am too lazy to find it right now.)


I have wondered over and over again whether this innovation is responsible for the sluggish performance. I too find that the system runs like molasses after a couple days up. The comparison with my similar-vintage personal laptop (which is running 10.6) is striking: after a couple days powered on, this laptop is much slower, with task switching particularly much worse. I have the dim feeling that Mission Control's lousy virtual desktop support has something to do with it, because people who don't use a lot of virtual desktops don't complain as much as I do, in my experience. I have no proof that this is the source of trouble, however.


Safari and its companion WebProcess also leak memory like it's going out of style (you can see this by watching the RSS rise like crazy). Several of these memory leaks were fixed in recent patchlevels, but they didn't get all of them. I think maybe Apple developers need to be reintroduced to ElectricFence. (It'd be nice if Chrome or Mozilla were better, but IME they're not. Mozilla is itself a bloated pig, so it's not like it's going to be ligher weight.)


If you're an old unix hand, ps -axwwv can be helpful.


I find that things are snappier after a reboot, too, which also makes me think there are memory leaks.


If I had any way to go back and ditch this OS in favour of its predecessor, I would, but apparently that isn't a good idea (and since this isn't my laptop, I'm not going to experiment). I sure hope 10.8 improves things, though. I used to love my Mac, but I hate this system with a passion.

May 31, 2012 8:12 AM in response to caloric

Just about everything you ever start never really exits -- processes never really terminate -- but are instead sent into a sleeping state.


That's not really accurate. Some processes may not actually terminate when the application quits (most will), but those processes will always be terminated whenever there is need for the memory they occupy. This is meant to improve performance. It should not adversely affect performance, and never has in my experience.


I'd give you the same advice I already gave LKHill... what you're seeing is not normal, so you need to try to find the source of the problem, using the same starting points I mentioned earlier.

May 31, 2012 8:32 AM in response to thomas_r.

Yeah, as I said, I was being purposely flip with the accuracy. What's interesting about the process model, however, is that sometimes when you think an application has exited, it actually hasn't. You can discover this with ps or other low-level tools, of course, but it's certain to be a surprise. Anyway, thanks for the better description.


I think the idea that this feature can't possibly adversely affect performance is whistling "Dixie". If the OS were smart enough to predict accurately when it was going to need gobs of memory, this would be a giant leap forward in computer scheduling. People would be beating down Apple's door to replace all their big iron database servers and web servers and so on with Apple boxes, because of Apple's ESP memory allocation model. Instead, Apple's model is one set of trade-offs. If your use patterns happen not to match the trade-offs well, you're going to be able to observe the trade-offs failing you.


My experience with other colleagues who have moved from 10.6 to 10.7 is that they also see dramatic issues with performance. Casual searches on the web suggest to me that lots of people have had this experience. I don't think it's true that it's "not normal". I think it is in fact normal under Lion. This is not that surprising -- Apple's history with major architectural changes in OS X has been spotty at best, and it usually takes a major release to sort matters out. If recent rumours that "all the cool kids" at Apple are now working on iOS and not OS X are true, then it is even less surprising. (The alternative you are suggesting is that all those people complaining are getting a product that is somehow otherwise faulty delivered to them; even if your suggestions are correct, the whole point of buying the integrated solution proffered by Apple is supposed to be that you don't have to worry about these problems.)

May 31, 2012 8:52 AM in response to caloric

I think the idea that this feature can't possibly adversely affect performance is whistling "Dixie". If the OS were smart enough to predict accurately when it was going to need gobs of memory, this would be a giant leap forward in computer scheduling.


That reasoning doesn't make any sense. It takes virtually no time at all to release a large amount of memory. What takes time is loading data into memory. By keeping data in memory as long as possible (and thus minimizing free RAM), the OS enables itself to be much faster. For example, if you were to quit Safari, and then needed to reopen it afterwards (but before Safari's processes have actually been made to terminate), Safari should open very quickly. But if another process needs the RAM that Safari is using, it is already in a state where it can be terminated and the memory released immediately.


My experience with other colleagues who have moved from 10.6 to 10.7 is that they also see dramatic issues with performance. Casual searches on the web suggest to me that lots of people have had this experience.


That kind of anecdotal evidence is not reliable. Such things have happened with not just each and every major version of Mac OS X since 10.0, but to a lesser extent with each and every minor update. Most of the time, the problem is something like incompatible third-party software or a corrupt system. It can also be due to inadequate hardware to handle the higher requirements of the newer system... in Lion's case, it's a 64-bit system, so it requires twice as much RAM for the same tasks as Snow Leopard. (Should have thought of that before... perhaps both of you simply need more RAM. In Activity Monitor's System Memory tab, compare the page ins and page outs values after you've been running for a while. If page outs is 10% or more of the page ins value, you need more RAM for the tasks you're trying to do.)

May 31, 2012 9:40 AM in response to thomas_r.

Thomas A Reed wrote:



That reasoning doesn't make any sense. It takes virtually no time at all to release a large amount of memory. What takes time is loading data into memory. By keeping data in memory as long as possible (and thus minimizing free RAM), the OS enables itself to be much faster.


Yes, of course. But paging out or back in is not free. As nearly as I can tell, 10.7 does more paging. At least, it sure appears that way. And paging is expensive, no matter how shiny and modern your system is.


That kind of anecdotal evidence is not reliable.


The plural of "anecdote" is not "data", but a collection of anecdotes on the same subject is, in fact, data. It appears that a number of people observe 10.7 to be slower.


the higher requirements of the newer system... in Lion's case, it's a 64-bit system, so it requires twice as much RAM for the same tasks as Snow Leopard. (Should have thought of that before... perhaps both of you simply need more RAM. In Activity Monitor's System Memory tab, compare the page ins and page outs values after you've been running for a while. If page outs is 10% or more of the page ins value, you need more RAM for the tasks you're trying to do.)


It isn't actually true that it requires "twice as much RAM", of course, unless the applications are so badly designed that they're all word-aligned on 32-bit words (in which case the much of the point of running a 64 bit system is sort of lost). But it could well be the case that the change to 64 bits is part of the problem, since paging is probably going to transfer more. If this machine needs more RAM, however, that's Apple's fault too: they sold my employer this machine with this operating system on it, and if it needs more RAM to be useful compared to a very similar laptop that I bought for the same purposes (my own; I'm doing the same job now with this company's laptop as I did before with my own) just prior to the Lion release, then they are selling preconfigured machines that are underpowered.


Anyway, you're quite right that, without a great deal of closely-matched benchmarks, it's pretty hard to say with any authority what's going on here. Of course, given that all we have are duelling anecdotes -- some saying "good performance" and others saying "poor performance" -- there is no way to tell whether there's a real issue. I've never seen any sort of rigorous benchmarking using multiple machines with merely two different OS images on them, all after having been run through a warm up workload, so I can't tell whether my experience is part of a pattern or not. If you're aware of such benchmarks, however, I'd be pleased to learn of them.


Thanks

May 31, 2012 1:17 PM in response to caloric

But paging out or back in is not free.


Releasing memory is not paging in or out. It's as close to free as anything really can be on a computer.


It isn't actually true that it requires "twice as much RAM"


Roughly speaking.


If this machine needs more RAM, however, that's Apple's fault too: they sold my employer this machine with this operating system on it, and if it needs more RAM to be useful [...] then they are selling preconfigured machines that are underpowered.


That depends on the tasks that they are put to. Some folks I've talked to are using machines with Lion and the default pre-installed RAM with no problems whatsoever. Others had to upgrade. (Like me... For what I was doing, I saw many beachballs, and very high page outs, after upgrading to Lion until I upgraded to 8 GB of RAM, then all problems disappeared.) And the tasks that you were able to do in a certain amount of RAM in Snow Leopard will not be able to be done in the same amount of RAM in Lion. You can't compare apples to oranges.


In any case, arguing about this is not productive. Those of us who have been here for a while see these reports literally with every OS release when there aren't actually any OS bugs. There's a major difference when there's a real bug (like the guest account bug in 10.6.0 and 10.6.1).


I've also learned that some people will never be convinced to start troubleshooting on their own, waiting instead for Apple to fix it for them. I sincerely hope you're not in that category, but if you are, I've also learned the futility of continuing to try to argue about it.

May 31, 2012 1:48 PM in response to LKHill

Lion manages memory quite a bit differently than older systems. People have a habit of looking at free memory and using that as a guage of system health. That is not a valid measurement. Free memory is wasted memory.


If you are experiencing actual performance issues, then those are what you need to focus on. Look at CPU usage rather than memory usage.

Jun 2, 2012 10:01 AM in response to etresoft

I tried the kextstat message and the response was:


Index Refs Address Size Wired Name (Version) <Linked Against>


which apparently indicates that there are no kernel extensions running.


I understand what you're all saying about unused memory going to waste, but for MacOS to operate "correctly" it would need to free up previously-allocated memory as it is needed by other or new applications, and it doesn't seem to be doing that. It's just acting like it's out of memory, with all processes slowing to a crawl.


I did check CPU utilization as well, and it's rarely over 25%. However, on one of my systems, Page Outs were about equal to Page Ins, substantially over the 10% "healthy" threshold that was suggested. So I upgraded to 10.7.4, and Page Outs are down in the acceptable range. The overnight bloat also seems to have gone away, but each app still creeps up with time, albeit more slowly now.


I too would like to return to the days of 10.6 where I didn't reboot for days - or weeks - and Microsoft apps didn't display spinning wheels with each reactivation task or any simple calculation or text move.


It seems clear that Lion's new process model is at least partially to blame here. With two completely different systems running (work MacBook, home iMac) plus my work partner's MacBook experiencing all the same symptoms, it's not likely my own setup. So I've also ordered an upgrade to 8 GB RAM.


I guess I'm just not accustomed to hating a new MacOS release, but between these performance problems and the inexplicable need to Duplicate TextEdit documents in order to do a Save-As (yeah, I know, Versioning is a great idea, blah blah - please get rid of it anyway) I really, really hate Lion.

Jun 2, 2012 10:44 AM in response to LKHill

However, on one of my systems, Page Outs were about equal to Page Ins, substantially over the 10% "healthy" threshold that was suggested. So I upgraded to 10.7.4, and Page Outs are down in the acceptable range.


Then, for whatever tasks you had been doing up to that point, you needed more RAM. It's pretty normal that your page outs are back down in the acceptable range if you haven't repeated whatever tasks caused it to spike like that.

Jun 2, 2012 2:39 PM in response to LKHill

LKHill wrote:


I tried the kextstat message and the response was:


Index Refs Address Size Wired Name (Version) <Linked Against>


which apparently indicates that there are no kernel extensions running.


That means you don't hve any non-Apple kernel extension. There are still lots of other possibilities for third party interference. Are you running any kind of anti-virus or clean-up software? Those aren't needed and will likely just cause problems.


I understand what you're all saying about unused memory going to waste, but for MacOS to operate "correctly" it would need to free up previously-allocated memory as it is needed by other or new applications, and it doesn't seem to be doing that. It's just acting like it's out of memory, with all processes slowing to a crawl.


"Free"? You are still looking at memory. If all processes are slowing to a crawl, then that is a problem worth investigating. If you can't get past the assumption that memory is the cause, you'll never figure it out.


I did check CPU utilization as well, and it's rarely over 25%. However, on one of my systems, Page Outs were about equal to Page Ins, substantially over the 10% "healthy" threshold that was suggested. So I upgraded to 10.7.4, and Page Outs are down in the acceptable range. The overnight bloat also seems to have gone away, but each app still creeps up with time, albeit more slowly now.


I too would like to return to the days of 10.6 where I didn't reboot for days - or weeks - and Microsoft apps didn't display spinning wheels with each reactivation task or any simple calculation or text move.


So, in other words, you fixed the memory problem but the performance issues remain. That tells me that it isn't a memory problem.


Also, because you seem unwilling to look past memory, I'm unwilling to accept your CPU usage claims. Sometimes it takes several attempts before I can get people to setup Activity Monitor correctly to see exactly what is going on with their systems. That is step 1. We haven't made it to step 1 yet.


It seems clear that Lion's new process model is at least partially to blame here. With two completely different systems running (work MacBook, home iMac) plus my work partner's MacBook experiencing all the same symptoms, it's not likely my own setup. So I've also ordered an upgrade to 8 GB RAM.


Here's the rub. If low memory isn't the cause, buying more won't help.


I guess I'm just not accustomed to hating a new MacOS release, but between these performance problems and the inexplicable need to Duplicate TextEdit documents in order to do a Save-As (yeah, I know, Versioning is a great idea, blah blah - please get rid of it anyway) I really, really hate Lion.


It's just an operating system and doesn't care how you feel. I strongly suspect that feeling is more the explanation of any issues you have. I hate Linux. I really do. Therefore, I don't use it. While I would love to help you figure out what is wrong with your machine, that will only work if you meet me halfway and help look. If you have already identified the cause, then you don't need my help. The problem is Lion. Erase your hard drive and the problem will be gone.

Jun 4, 2012 5:15 AM in response to LKHill

Here's what I know, with Snow Leopard, my MacBook was faster for a longer period of time. With Lion, I have to purge or restart a couple of times per day. Before Lion, I never used Terminal or purge, now I have to. I have added no new apps. I can't go back to Snow Leopard because I'm using Icloud, so I'm stuck with Lion and purge or restart. It reminds me of Windows defrag problems. The real question is when is Apple going to deal with this problem, or if it's not an Lion problem, reveal to us just what's going on. If I wanted to be a computer hobbyist, I could have stuck with win XP, defrag and scan disk. I'm waiting, Apple!

Jun 4, 2012 5:34 AM in response to Bobdc6

Bobdc6 wrote:


The real question is when is Apple going to deal with this problem, or if it's not an Lion problem, reveal to us just what's going on. If I wanted to be a computer hobbyist, I could have stuck with win XP, defrag and scan disk. I'm waiting, Apple!

What problem? If you are having a problem, you need to start your own question to give someone an opportunity to look at it. It isn't normal to use Terminal commands to purge memory. I've never done it and I've never seen it recommended for anything. So why are you doing it? Describe your problem, what third party software you have installed, and try troubleshooting tips that people suggest. If you just sit back and wait for Apple to do something, you will be waiting forever.

Jun 4, 2012 6:19 AM in response to etresoft

Thanks for your interest, but I posted this hoping that someone from Apple reads this stuff (I send bug reports too). I posted on this question because my problem seems to be the same or similar to LKHill's. I have no intention of trouble shooting a problem that started with my downloading Lion (that's why I'm blaming Lion). I have high confidence that Apple will solve this situation fairly soon, that's why I've paid a bunch of money for four Apple computers and an Iphone, tossing my MS computers in the trash. Apple is still a LOT better than Microsoft, even with using Terminal-purge and restart daily. It takes a lot less of my time than endless security downloads, defrag, virus scan, periodic reinstall of the OS, etc., a characteristic of Microsoft OS.


( I use Terminal-purge to stop my spinning beach ball, it works for me)

Memory leaks in Lion?

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