
Mountain Lion seems to have addressed the memory management issues in OS X - fields
http://workstuff.tumblr.com/post/28556080639/mountain-lion-seems-to-have-partially-addressed-the
======
otterley
It's important to get the terminology correct when discussing VM behavior.
Page-outs are not identical to swap-outs. And unfortunately, due to the age
and architecture of the Mach kernel, there's no way I'm aware of on OS X to
measure the rate of the latter.

Page-outs refer to a file-backed page being committed to disk; these are
perfectly normal and expected (program writes to a file, kernel eventually
commits to disk). Every OS guarantees that file-backed pages be committed
within some reasonably short period of time to reduce the risk of lost data in
the event of a power outage (the sync interval).

A high page-out rate doesn't necessarily imply memory pressure; it may simply
mean some program running on the system is writing to files frequently.
However, memory pressure may temporarily increase the page-out rate if the
sync interval hasn't yet kicked in.

Swap-outs, on the other hand, relate to anonymous memory pages (i.e. the
heap). Swap-outs, in contrast to page-outs, are generally bad and indicate
severe memory pressure.

~~~
pooriaazimi
> _Every OS guarantees that file-backed pages be committed within some
> reasonably short period of time_

Just curious: is that "short period of time" usually in order of seconds or
minutes? (I know different OSes have different defaults; I just want to know a
ballpark figure!)

~~~
IsTom
It's there to keep disk from trashing the head around, so I believe it's not
more than a few spins of the platters.

~~~
pooriaazimi
:) Actually, I wanted to ask whether it's in order of milliseconds or seconds!
Don't know how the "minute" found its way into my comment. A minute is reaaaly
long.

------
kalleboo
I still ended up with an 8 GB page file after a few days of regular usage
(nothing too hard like VMs or anything - just your typical Xcode dev workflow,
including opening up Photoshop once or twice to export graphics).

This is on a MBP with 8 GB RAM.

I never had any memory-related performance issues in Lion, (maybe because I
have an SSD), but I always end up with a big pagefile of stale data.

~~~
DrJokepu
Most modern operating systems try write the contents of the physical memory to
the page file at the first good opportunity (well before it's needed) in order
to save time when the page is actually paged out, so it's perfectly normal to
have a page file that is at least as large as your physical memory.

~~~
wmf
AFAIK VMS and NT behave that way but Linux is much lazier. Especially if your
swap is dynamically allocated (as in OS X) you don't want to swap out unless
there is actual memory pressure.

------
whalesalad
It seems as though a lot of people are noticing some speed enhancements. I
haven't quantified any of it, so my experience is all anecdotal, but I
definitely notice the boost as well.

The changes in Mountain Lion have been subtle, but I really love the upgrade.
I performed a full disk backup which took the longest amount of time. The
actual install (2012 MacBook Air) took like 15-20 minutes. If anyone is in
doubt, definitely do yourself the favor and upgrade. Typically I am hesitant
to do major OS upgrades due to things like python or ruby breaking most of my
local websites ... everything works great!

I had to modify some apache2 settings (I use the built-in webserver for PHP
development) but that was about it. Oh also, apache is still there. A lot of
people think that it's gone because the preferences pane is missing, but it's
still hiding within the belly of the beast.

I feel like I can throw anything at this. I've never multitasked like this
before.

------
DrJokepu
One of the things I've noticed is that the new Xcode 4.4 (released the same
time as Mountain Lion) seems to be an awful lot snappier to me. My theory is
that this is happening because they might have switched Xcode from being
garbage collected to ARC (since it used to be GC ever since Snow Leopard came
out but GC is now deprecated).

~~~
chucknelson
Does anyone know if there is a way to monitor xcode and find out if it's GC or
ARC?

~~~
msbarnett
You can just use otool to dump the Objective-C information out of the MachO
executable:

    
    
         otool -o /Applications/Xcode.app/Contents/MacOS/Xcode
         .....
         Contents of (__DATA,__objc_imageinfo) section
           version 0
             flags 0x6 OBJC_IMAGE_SUPPORTS_GC
    

That's for Xcode 4.4. So yes, it's still being built for Garbage Collection.

------
tambourine_man
We've been hearing this for a long time:

“free memory is wasted memory” vs “inactive memory is never released”

“Purge is the worst thing you could do” vs “Purge solves the issue”

We have the kernels's source[1] and DTrace. Let's get some real data?

[1]<http://opensource.apple.com/source/xnu/xnu-2050.7.9/>

------
tedsuo
Haven't seen the paging issues Adam was noticing, but I'm still gobsmacked by
the amount of memory some applications seem to take. The OS (kernel_task, mds,
WindowServer, and friends) regularly eat up .75 of a gig, and Firefox consumes
.5 - 1 gig without much effort (other browsers seem to have a similar
profile).

Quick poll, what are you running, and what's your memory consumption? Here's
me:

Currently running: Firefox, Spotify, Mail, Calendar, Terminal, Mongo (mongo
using 100mb).

Memory Used: 3.75 GB

~~~
blinkingled
It is definitely better overall with ML in that it is no longer ridiculously
slow but memory consumption for typical set of tasks still is way higher than
either of Linux and Windows.

For instance I have KDE4 running on Linux with Firefox, Amarok, Kopete,
Konsole and all other default services (ssh etc). Used memory is 1.1GB.

I've ML running with Firefox, Terminal.app, Activity Monitor in addition to
the defaults. Any my used memory is 3.92GB. Wired is 1.75GB and Swap used is
11MB!

My experience with Windows 7 is also lot better than ML - it tends to be bit
more than Linux but in the same ballpark.

Edit: To put this in perspective - I just realized that my work laptop (that I
RDP into and never reboot) with all possible bloatware loaded and running -
Word, Outlook, RDP, Lync 2010, Java Backup process, Enterprisey stuff, Firefox
with couple tabs etc. is taking up only 2.83 GB! Apple really has a memory
usage problem with OS X.

~~~
stephencanon
Unused memory is wasted. You should be complaining about the system that
_doesn't_ use all available memory.

~~~
blinkingled
Windows and Linux don't leave unused memory around - both use it heavily for
page cache. However what we have a problem here with is active/resident memory
use and/or VM subsystem making no so smart decisions(this part seems to have
gotten better with ML).

So the end result is that when Windows and Linux can be quite usable with 2GB
RAM with a rotational disk, for similar workload OS X slows down quite a bit.

------
kevinconroy
I can concur with OP. My MacBook Pro suffered severe paging issues under Lion,
but seems to be (mostly) gone in Mountain Lion. Running Eclipse, Photoshop,
Chrome, and Parallels at the same time is possible once again without major
slow down on my machine. As always, YMMV.

------
T_S_
Odd. I had this problem in 10.6 (Snow Leopard) and it went away when I
upgraded to 10.7 (Lion). The most obvious symptom is the machine does not seem
to be able to make use of the inactive memory (the blue slice of the pie in
Activity Monitor). I did not notice the problem at all when I first started
using 10.6. When I hunted around on the help forums a few months ago I found
lots of users with the symptoms, but nobody acknowledging the "validity" of
the problem. In fact a lot of deniers out there. I wonder if it was quietly
fixed or will recur after the system gets used for a while.

------
udp
I don't suppose anyone can comment on whether Mountain Lion has done anything
for the mouse lag issue[1]?

I can't upgrade yet because I disabled HFS+ journaling and nothing seems to be
able to re-enable it (the installer requires journaling to be enabled).

[1] [http://d43.me/blog/1205/the-cause-for-all-your-mac-os-x-
mous...](http://d43.me/blog/1205/the-cause-for-all-your-mac-os-x-mouse-
annoyances/)

~~~
evoxed
I'm sure someone will be along to correct me quick enough if I'm wrong, but
last year when I was upgrading to Lion I had the same issue (journaling turned
off) and was able to turn it back on with minimal pain by doing it from the
Snow Leopard boot disc (Disk Utility, of course).

~~~
udp
Unfortunately that just gets me a helpful "Journaling could not be enabled". I
guess something got messed up when I was writing to the volume from Linux.

~~~
lloeki
What about:

    
    
        $ diskutil enableJournal /dev/diskXsY
    

ML's diskutil(8) says:

    
    
         enableJournal device
                    Enable journaling on an HFS+ volume.  This works whether or not
                    the volume is currently mounted (the volume is temporarily
                    mounted if necessary).  Ownership of the affected disk is
                    required.
    
         disableJournal [force] device
                    Disable journaling on an HFS+ volume.  This normally works
                    whether or not the volume is currently mounted (the volume is
                    temporarily mounted if necessary).  If the force option is speci-
                    fied, then journaling is disabled directly on disk; in this case,
                    the volume must not be mounted.  Ownership of the affected disk
                    is required.
    
         moveJournal external | internal [journalDevice] device
                    external will create a 512MB Apple_Journal partition out of
                    journalDevice and an HFS+ partition will be created out of the
                    remaining space if available; journalDevice must be a partition,
                    not a whole-disk. The journal for device will then be moved
                    externally onto the newly created Apple_Journal partition.
    
                    internal will move the journal for device back locally.
    

I don't know if it can work on the mounted root filesystem so you may want to
try that from the recovery partition.

------
cicloid
Since the GM, I also noticed this on my production machine. Previously I had
custom settings for the dynamic pager, but it seems that is not longer
necessary.

Subtle changes and I'm happy with them. Probably the next year, we'll see some
subtle improvements on the backend.

------
bsimpson
This is the reason I installed Mountain Lion. I've only used it a bit in the
last few days, but I haven't seen crazy amounts of mds RAM usage since
installing either.

------
Karunamon
Only thing holding me back from upgrading is the complete lack of wanting to
hex edit my ATI kext again.. heck it might not even be compatbile with ML.

Hackintoshes :/

~~~
rangibaby
What kind of card do you have? Hackintoshing has gotten a lot friendlier in
the last few years. I upgraded a hackintosh I built for a friend from 10.6 to
10.8 and was pleasantly surprised by how everything "just worked" with minimal
kext juggling.

~~~
Karunamon
Gigabyte Radeon 6850. What'll happen is, you have to choose a specific
framebuffer configuration to even boot. 2 of these work with my card, only one
of which allows hardware acceleration to work right _and_ allows both DVI
ports to work.

The one that allows hardware accel on a single screen is actually the right
one for the card. The hex editing is to change the display outputs to enable
the second head.

~~~
jonhendry
I'm using an XFX 6870, two-headed, on my Hackintosh, and didn't have to edit
anything. I'm pretty sure hardware acceleration is working, too.

~~~
Karunamon
Those are sufficiently different that you likely don't have the problem. The
6870 uses a different framebuffer personality than the 6850, and likely the
fact that it's a different manufacturer might ameliorate the problem
altogether.

~~~
jonhendry
Which hackintosh tools did you use? I used Unibeast/Multibeast.

~~~
Karunamon
Multibeast from CD. I don't think this is an install problem though, there's
an absurdly large thread about this on insanelymac:
<http://www.insanelymac.com/forum/index.php?showtopic=273937>

------
taude
My battery life seems to last as long as it did on Snow Leopard, too.

~~~
cydonian_monk
I'm seeing the exact opposite, but for a different reason. On Lion I could put
my MBP to sleep and only lose about 5-10% of the battery over 8 hours. Now on
ML I lose ~40%, with nothing running. I turned off location services today to
see if that's the culprit.

As for actual on-battery use - yes, the battery life is noticeably improved
over Lion.

~~~
dailyrorschach
Are you running Power Nap on battery? Also are you leaving USB items plugged
in?

On Lion at least I noticed that if I left my USB HD in, and closed the lid on
battery it killed it, every time. There was an Apple Support thread confirming
that.

~~~
fields
Apparently, having an external disk mounted prevents the system from going
into some sleep modes, which will kill the battery:

<http://support.apple.com/kb/HT1776>

~~~
cydonian_monk
That could quite possibly be it, as I don't always unmount my fileservers when
I leave home. I'll make sure to do that from now on, and might just write a
script to handle it. Thanks.

I wonder if this same issue would crop up with the Amazon Cloud Drive.... It's
not much more than a CIFS/NFS mount.

------
Flow
Yup, memory management seemed to be fixed as of 10.7.4 even.

I've found new bug in ML, whenever I switch users, Mountain Lion seems to
think I've a desktop much smaller than what I actually have. And sometimes the
"virtual" desktop isn't even positioned at 0,0 on my actual desktop. :-/

------
chiph
OK, that's enough reason to do the upgrade.

Parallels gets abysmally slow for me when TimeMachine starts up.

~~~
bchen
This is slightly off topic, but make sure you are on the latest version of
Parallels before doing the upgrade. For some reason, Parallels 6, which is
less than 2 years old, does not support Mountain Lion. Personally, I do not
care about the new features in Parallels 7, but was a bit annoyed when forced
to upgrade.

~~~
adestefan
I got bit by the same thing with VMware. You must be on Fusion 4 for Mountain
Lion. Sucks because I had no plans on upgrading.

~~~
jasomill
There's a free Technology Preview of Fusion 5 that's time-limited, but
probably not so much that it wouldn't work until Fusion 5 ships. Mountain Lion
is officially supported as a host and guest. I've been using it daily for a
couple months to run Windows (7 and Server 2008 R2, plus the various previews
of 8 and Server 2012), FreeBSD, and OS X (Lion, Snow Leopard Server, and
Leopard Server), and it seems stable.

------
astrange
I would not describe this as "the memory management issues in OS X". It should
be obvious to anyone how much of an oversimplification that is.

~~~
cellularmitosis
I'm not so sure. When someone says "the memory management issues in OS X", I
feel pretty confident in assuming specifically which problem they are
referring to.

There are some memory models which appear to behave in a way which is
relatively psychologically pleasing, and some which do not.

When users are using a program, there are certain times when they have a
reasonable expectation that the machine is going to need some time to complete
a task ("click and wait"). There are other times when they have no such
expectation, and if the machine makes them wait, they get annoyed.

It isn't about the total time they have to wait, its about whether that
waiting occurs when they expect it to or not.

Further, when they start to experience these unexpected, annoying pauses, they
have a certain expectation that adding more RAM to the system should solve the
problem, and when it doesn't, their annoyance only intensifies.

Having used both Linux and OS X as a desktop, I'm going to claim that the
Linux VM behavior is pleasing in the ways described above, and the OS X
behavior is not.

My understanding is that this is due to just one underlying behavior of the
VM: When experiencing memory pressure, Linux (generally) favors evicting
filesystem cache over swapping out stack/heap memory to disk, and OS X does
not.

~~~
unconed
It's pretty hilarious that this is in one area in which Linux put the user
first, while OS X has been plagued by the engineers saying "there is no
problem" over and over again.

------
pooriaazimi
Question: (2009 15" MBP, 8GB 1333MHz RAM, 7200rpm HDD, Mountain Lion)

I have zillions of apps open.

    
    
        1GB wired, 3.25GB active, 1GB inactive, 2.55 free
    
        757,197 Page Ins
    
        0 Page Outs
    

It's confusing... If I haven't "swapped out" (page out) anything to disk, then
how come I've "swapped in" (page in) 750,000 pages _from_ the disk?

~~~
achivetta
If you mmap a file, and then access the mmap'ed region, pulling in the pages
of the file from disk is considered paging the file in. Watch the output of
fs_usage to see examples of this.

------
LoganCale
It's much, much worse for me. Things go into Inactive memory, which is fine,
but then it doesn't get freed when it's needed, or else it does so very
slowly. So I have 20 MB of Free memory and 4 GB of Inactive and everything
slows to an unusable crawl and I have to run `purge` to get my computer to
start behaving properly again.

------
chatmasta
Does anyone still have a 4gb MBP? I'm still on SL and wondering if I should
switch.

~~~
inuhj
I had 4gb up until I upgraded to ML. After 2-3 days on ML I noticed my free
memory was around 300mb. I upgraded to 16gb for $65(cheap Komputerbay ram from
amazon.com). An 8gb upgrade is ~45 for crucial 1.35V ram. I think its worth
it.

~~~
chatmasta
Cool, thanks for the advice. I didn't even realize upgrading memory was so
easy. I have a 2010 unibody, and Apple claims the maximum memory it supports
is 8gb. Is that not really "true?"

~~~
dedward
Dig around - the 16 gig aftermarket upgrade may have been confined to some
early 2011 mbp's - the 13" for sure (mine's on the way)

------
Perceval
I am running Mountain Lion on a 24 GB ExpressCard (about 3 GB free) with 4 GB
of RAM. After upgrading to Mountain Lion I am getting a "Hard disk is nearly
full" message much more frequently. Almost never seen that on Lion. Could this
memory management change be the culprit?

------
slig
Anyone did the upgrade from SL? Is a clean install always recommended?

~~~
ChiperSoft
Clean install is always recommended no matter which OS you're coming from.

~~~
ghshephard
Recommended by who? The mac pundits that I listen to, Gruber, Siracusa,
certainly don't seem to have a problem with upgrading in place on OS X.

And, "no matter which OS" is definitely incorrect. I've done an in-place
upgrade of an OpenBSD system for the better part of six years (twelve
upgrades, twice a year). The _recommended_ approach on that platform is to do
_in place_ - not clean install. It's how you maintain library compatibility
with all your legacy apps.

~~~
jasomill
I've had no more problems with the Lion machine I upgraded to Mountain Lion
than I have with the two machines I did clean (USB stick, NetInstall) installs
on, and the same was true when I moved from Snow Leopard to Lion.

With that said, there are fewer things that can _automatically_ go wrong in
any clean install (as opposed to the things that can go wrong _manually_ with
a clean install, like forgetting to deactivate Adobe CS, or that scripts
accustomed to sshing in to your server don't take kindly to unannounced host
key changes).

------
chadrs
> addressed the memory pun intended?

~~~
fields
No, but that's funny.

------
89a
This guys initial advice was terrible and should never have been paraded
around as a solution

~~~
cellularmitosis
Really? Because it solved my problem completely. I have to reboot when my
system runs out of RAM, but I'd much rather do that once every two weeks than
be constantly bombarded with beach balls.

