Live data from Hacker News

Something is deeply broken in OS X memory management

workstuff.tumblr.com

121–130 of 269 posts

Re: Something is deeply broken in OS X memory management

#121
The core reason that this happens is that OS X uses a memory management mechanism called Unified Buffer Cache (http://kerneltrap.org/node/315 is the only reference I can find on this).

This seems like a good idea to unify paging and disk cache memory, but it actually isn't. This means, that if you do a lot of I/O, resident pages (i.e. your programs) can actually get pushed out of memory to free up RAM for the disk cache. This degenerates pretty badly in scenarios like using VMs, since you're also using large sections of mmap'd memory.

This doesn't happen on NT or Linux, because disk cache can only be turned into memory (i.e. making disk cache smaller), not the other way around; the policy is "Disk cache gets whatever's left over, Memory Manager has priority"

Unfortunately, the only thing you can really do about it, is have a machine with a huge amount of RAM, which will kind of help.

Re: Something is deeply broken in OS X memory management

#122
Thank god for this article. My wife is a photographer making heavy use of Lightroom on her 17" MBP and has been experiencing these exact problems for a year or two. We've tried everything to fix it, rebuilding the system from scratch, to no avail.

She had 4 gigs of RAM which we recently upped to 8gigs which reduced the severity of the problem.

I really, really hope this is something that gets fixed in Mountain Lion. Tasks that should take 20 seconds take 10 minutes or more.

It's good to know she's not crazy.

Re: Something is deeply broken in OS X memory management

#123

I have an 8-way Xeon Mac Pro w/ 20GB of RAM, almost half of which is 'free' at any point during the day unless I'm doing something really out of the ordinary. Yet it still swaps to disk ALL THE TIME and a new Terminal.app window can take up to 5 seconds to open. I really don't give a shit how it's not "technically" broken - that's broken from an experience point of view. And I haven't re-installed the OS (this was an…

Putting an SSD in for me solved all the problems you mentioned. Haven't seen a beach ball since.

Lion has probably been optimized for SSD since Apple is quickly getting rid of spinning disks in their entire line up.

Re: Something is deeply broken in OS X memory management

#124

Earlier quoted context omitted.

> "That delay is /usr/bin/login searching the system logs so that it can display the date and time of your last login." Am I missing something? `w` on my linux system takes well below one second: [burgerbrain@eeepc] ~ % time w 14:11:18 up 19:41, 6 users, load average: 0.27, 0.10, 0.14 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT REDACTED w 0.01s user 0.05s system 61% cpu 0.096 total I can't imagine why anything like that…

That shows your currently active login, which is of course in main memory. Your most recent login may well no longer be active, and so you have to search the log files.

Ah yeah, had a brain fart there. Even so, `last` is similarly fast.

Re: Something is deeply broken in OS X memory management

#125

I have an 8-way Xeon Mac Pro w/ 20GB of RAM, almost half of which is 'free' at any point during the day unless I'm doing something really out of the ordinary. Yet it still swaps to disk ALL THE TIME and a new Terminal.app window can take up to 5 seconds to open. I really don't give a shit how it's not "technically" broken - that's broken from an experience point of view. And I haven't re-installed the OS (this was an…

> I haven't re-installed the OS (this was an App Store upgrade from Snow leopard) because that's a major pain in the ass as this is an actual workstation used to do actual work.

This has never been hard to do on OS X since 10.0 because they followed the Unix convention of separating user data from system files. It is, of course, rarely necessary unless you've used superuser access to seriously muck with things under /System.

I've done this repeatedly over the years when dealing with beta releases & system migrations and it's never taken much longer than the time needed to copy the files.

Re: Something is deeply broken in OS X memory management

#127
post #25
post #11

Earlier quoted context omitted.

Cmd line syntax, for the lazy, please?

I made a bash script for it and I'll share it, hacker 2 hacker. Goes a little something like this: #!/bin/bash purge

post it to GitHub so I can fork it to support zsh

Re: Something is deeply broken in OS X memory management

#128
post #4

Not this again, we already went through this a few weeks ago. Back then, I thought the conclusion was that there is nothing broken about OS X memory management, and that with every 'fix' you come up with, you will just introduce another degenerate corner case. The same holds for any OS, trade-offs are made that may have some negative effect in some cases, to the benefit of the general cases. I don't recognize any of…

>we already went through this a few weeks ago. . . . Back then, I thought the conclusion was that there is nothing broken about OS X memory management I read through the comment of a few weeks ago, and I did not see anything conclusive or even anything that would outweigh my subjective impressions that something about Lion on my (stock) 2011 Mac mini is causing unnecessary lack of responsiveness. You might be uncomfo…

Do you have a link? I tried to search hn but, alas, in vain.

Re: Something is deeply broken in OS X memory management

#129
post #82

Earlier quoted context omitted.

I'm running on a 160GB HDD (nearly full), 2GB ram, on a 4 year old MacBook. I always have iTunes, Xcode, Safari/Chrome running with multiple tabs, and a mail client (Sparrow). The system originally ran Leopard and I upgraded to SL and then Lion. I wouldn't say it's slow. It's definitely getting slower but that's expected since it's such an old system. Could it be that you're just expecting too much from your computer…

"It's definitely getting slower but that's expected since it's such an old system." I see this sentiment a lot, but I disagree with it. What are "iTunes, Xcode, Safari/Chrome, and a mail client" doing now that they weren't doing four years ago? Is it enough to justify their latest versions feeling less responsive than their versions from four years ago?

Safari/Chrome: websites are more complex, more image-heavy, and more JavaScript-heavy

iTunes: layers of software for dealing with Wi-Fi sync, Ping social network, iTunes Match, and so on

Mail Client: totally agree with you there...

But I still pretty much agree with you overall...

Post reply on HN