Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Ritmo

macrumors member
Original poster
Mar 27, 2009
53
44
Finland
Ok. It seems that it doesn't matter how much ram you have, OSX will it eat just for fun. When I had 4Gb I thought "well I am using virtual machine and quite a lot of apps". Buying 8Gb helped a bit but it was still swapping. But today I've seen the worst and no matter how big apple fan boy you are, you have to admit this is pretty bad.
 

Attachments

  • SystemUIServer.jpg
    SystemUIServer.jpg
    19.2 KB · Views: 240

GGJstudios

macrumors Westmere
May 16, 2008
44,545
943
Ok. It seems that it doesn't matter how much ram you have, OSX will it eat just for fun. When I had 4Gb I thought "well I am using virtual machine and quite a lot of apps". Buying 8Gb helped a bit but it was still swapping. But today I've seen the worst and no matter how big apple fan boy you are, you have to admit this is pretty bad.

Mac OS X will use all the RAM you have installed. That's what it's there for. The only thing you need to watch for is page outs. If you have no page outs with your normal workload, you can forget about memory issues. Page outs are cumulative since your last restart, so the best way to check is to restart your computer and track page outs under your normal workload (the apps, browser pages and documents you normally would have open). If your page outs are significant (say 1GB or more) under normal use, you may benefit from more RAM. If your page outs are zero or very low during normal use, you probably won't see any performance improvement from adding RAM.

Mac OS X: Reading system memory usage in Activity Monitor

Running a VM is obviously placing high demands on memory. If that represents normal use for you, you may need more RAM.
 

Ritmo

macrumors member
Original poster
Mar 27, 2009
53
44
Finland
Mac OS X will use all the RAM you have installed. That's what it's there for. The only thing you need to watch for is page outs. If you have no page outs with your normal workload, you can forget about memory issues. Page outs are cumulative since your last restart, so the best way to check is to restart your computer and track page outs under your normal workload (the apps, browser pages and documents you normally would have open). If your page outs are significant (say 1GB or more) under normal use, you may benefit from more RAM. If your page outs are zero or very low during normal use, you probably won't see any performance improvement from adding RAM.

Mac OS X: Reading system memory usage in Activity Monitor

Running a VM is obviously placing high demands on memory. If that represents normal use for you, you may need more RAM.

Sir, are you working for apple? Because that i so helpful!
Obviously I'm not using mac for the first time. And as you can see from the picture I'm complaining about how OSX manages the RAM. It's swapping 0,5Gb for no reason because there is still 3Gb of inactive RAM that could be released for use.
 

dyn

macrumors 68030
Aug 8, 2009
2,708
388
.nl
Than it is a very wise idea to read up on what swap is exactly and what its uses are. The OS will swap when it runs out of virtual memory addresses. In some cases apps actually make use of swap to save on RAM. VMware Fusion is one of those. It is why it is so memory efficient. Swap is not very fast memory is whatever isn't needed right away can be put in there. By doing that you free up the much faster RAM which will make certain operations a lot faster.

It has nothing to do with being a fanboy, it has everything to do with knowing what on earth swap is and how it works. That and the overall memory management in OS X as explained in GGJstudios link. In other words: read the darn link!
 

dcorban

macrumors 6502a
Oct 29, 2007
914
30
The basic idea is that the size of the swap file is almost meaningless in regards to performance.

Stop staring at the stats and use the computer. When it starts feeling slow due to swapping, then be concerned.
 

nutmac

macrumors 603
Mar 30, 2004
6,053
7,315
Mac OS X will use all the RAM you have installed. That's what it's there for. The only thing you need to watch for is page outs. If you have no page outs with your normal workload, you can forget about memory issues. Page outs are cumulative since your last restart, so the best way to check is to restart your computer and track page outs under your normal workload (the apps, browser pages and documents you normally would have open). If your page outs are significant (say 1GB or more) under normal use, you may benefit from more RAM. If your page outs are zero or very low during normal use, you probably won't see any performance improvement from adding RAM.
You are passing outdated information.

Much of the inactive memory is used for disk cache. In theory, when free memory is running low, OS X's dynamic pager is supposed to flush disk cache from inactive memory.

Both Lion and Mountain Lion (especially Lion) are not very good at reclaiming memory. Running "purge" command from Terminal (you may need to install Xcode) will flush disk cache out of inactive memory and return most of it back to free memory pool. But that is obviously not something any of us wants to do.

Adding more RAM will certainly decrease the likelihood of free memory running out, but if you rarely reboot your Mac, you will probably run out of it eventually.
 

GGJstudios

macrumors Westmere
May 16, 2008
44,545
943
It's swapping 0,5Gb for no reason because there is still 3Gb of inactive RAM that could be released for use.
You don't know that. As page outs are cumulative since your last restart, they could have occurred at any time, not at the time of the screen shot, when there is both free and inactive memory available.
You are passing outdated information.
No, it's not outdated. I have yet to see anyone provide proof that page outs are occurring at a time when there is free or inactive memory available, even on Lion or ML. To prove that, you need a video showing the page outs increasing while free and inactive memory is available at the time of the page outs. People don't seem to grasp the fact that the page outs reading is not a real-time indication that page outs are occurring now, but rather a historical accumulation of page outs that have happened in the past, since the last restart.
 

dyn

macrumors 68030
Aug 8, 2009
2,708
388
.nl

GGJstudios

macrumors Westmere
May 16, 2008
44,545
943
The OS will swap when it runs out of virtual memory addresses.
Actually, it swaps when it runs out of physical memory, not virtual.
As far as a program is concerned, addresses in its logical address space are always available. However, if an application accesses an address on a memory page that is not currently in physical RAM, a page fault occurs.
 

sidewinder

macrumors 68020
Dec 10, 2008
2,425
130
Northern California
No need because it is 100% correct. If you want to take part in this discussion I strongly suggest that you do your homework properly. Apple is talking in its developer documentation about virtual memory addresses. When it runs out of these addresses it will start to shift things in memory and eventually swap.

Now go read up on how it really works and admit you are wrong in every way ;)

Maybe you should go read up on how it really works.

The system never runs out of "virtual memory addresses" as you call them. Each process has a logical (virtual) address space created for it by the virtual memory manager. This space is chopped up into 4KB pages. This logical address space is always available to the process.

What the system can do is run out of physical RAM. That is when these pages can get swapped out of memory onto disk and vice versa.

So this sentence of yours:

The OS will swap when it runs out of virtual memory addresses.

Is completely incorrect.

S-
 
Last edited:

nutmac

macrumors 603
Mar 30, 2004
6,053
7,315
No, it's not outdated. I have yet to see anyone provide proof that page outs are occurring at a time when there is free or inactive memory available, even on Lion or ML. To prove that, you need a video showing the page outs increasing while free and inactive memory is available at the time of the page outs.

I don't really want to create a video to prove you wrong but if I run memory intensive task like (1) Final Cut Pro export or analyzing clips, (2) Aperture view entire photos, (3) Handbrake encode 1080p movie, inactive memory will gradually increase and deplete free memory. Eventually, free memory reaches 0 MB and page outs count starts to go up from 0. FYI, my 2011 MacBook Pro has 16GB RAM.

This issue is also documented by Adam Fields as well as 56-page long discussion at Apple's support community site.
 

GGJstudios

macrumors Westmere
May 16, 2008
44,545
943
I don't really want to create a video to prove you wrong but if I run memory intensive task like (1) Final Cut Pro export or analyzing clips, (2) Aperture view entire photos, (3) Handbrake encode 1080p movie, inactive memory will gradually increase and deplete free memory.
Inactive memory doesn't "deplete" free memory. Read the link in my first post to understand what free and inactive memory is, and how memory is marked as inactive.
Eventually, free memory reaches 0 MB and page outs count starts to go up from 0.
At the time page outs start increasing, free memory is zero, but what about inactive memory? That's the part that people claim, but never prove.
 

nutmac

macrumors 603
Mar 30, 2004
6,053
7,315
Inactive memory doesn't "deplete" free memory. Read the link in my first post to understand what free and inactive memory is, and how memory is marked as inactive.

At the time page outs start increasing, free memory is zero, but what about inactive memory? That's the part that people claim, but never prove.

Sure it does. Inactive memory is not directly available to applications. OS X will use free memory for disk cache, which then becomes inactive memory. At its discretion (e.g., when free memory is running low), it will release inactive memory back to free memory pool, by doing things like flushing disk cache.

Unfortunately, Lion and (to less extent) Mountain Lion do not release inactive memory very well. Murphy's Law is that as inactive memory rises, free memory will decline. You just can't have both.

When you run out of free memory, OS X will start swapping memory (page out) into disk (virtual memory). And when you start paging out, you will start to get things like beach balls (less severe on flash storage/SSD). The only workaround at this point is to reboot your Mac.

Here's before:
before.png

Here's after:
after.png

In theory, this after state shouldn't happen.
 

GGJstudios

macrumors Westmere
May 16, 2008
44,545
943
Sure it does. Inactive memory is not directly available to applications.
Directly from the Apple link I first posted:
Inactive memory is available for use by another application, just like Free memory.
When you run out of free memory, OS X will start swapping memory (page out) into disk (virtual memory).
Page outs occur when you have no free or inactive memory.
And when you start paging out, you will start to get things like beach balls (less severe on flash storage/SSD). The only workaround at this point is to reboot your Mac.
You don't have to reboot. If you close the apps that are placing high demands on memory, that memory will be freed up by Mac OS X, returning to either free or inactive memory, or both.
Here's before:
Here's after:
In theory, this after state shouldn't happen.
As I said before, the after picture shows that page outs occurred since the last restart, but does not prove that they occurred at a time when there was inactive memory available. I would be happy to concede that this is happening, but I've never seen any proof.
 

dukebound85

macrumors Core
Jul 17, 2005
19,131
4,110
5045 feet above sea level
Directly from the Apple link I first posted:


Page outs occur when you have no free or inactive memory.

You don't have to reboot. If you close the apps that are placing high demands on memory, that memory will be freed up by Mac OS X, returning to either free or inactive memory, or both.

As I said before, the after picture shows that page outs occurred since the last restart, but does not prove that they occurred at a time when there was inactive memory available. I would be happy to concede that this is happening, but I've never seen any proof.

From my experiences, as I keep posting about on this topic but you never acknowledge, if I run an app that requires a bunch of memory, inactive != free. My experience is running matlab files manipulating multiple variables well over 5 gigs (sometimes up to 10gigs) apiece

Running the purge command does help with the task I am trying to conduct in those cases as it frees up the inactive ram for matlab, which is constantly wanting as much as it can get. When I have a bunch of inactive memory and no free memory, I get loads of pageouts and very poor performance.

Not sure why you keep saying they are the same when they are clearly not in situations I have expereinced, told you about, yet ignored when you keep posting the same info.
 
Last edited:

SpyderBite

macrumors 65816
Oct 4, 2011
1,262
8
Xanadu
If the problem doesn't exist for everybody (I am not experiencing the same issue as you) then how can you be certain that it is something that Apple needs to address and it isn't something localized on your system or similar setup?

Tech Support 101: if everybody is having the same problem it is a problem with the code. If only you are having a problem it is a problem with the way you are using the code.
 

nutmac

macrumors 603
Mar 30, 2004
6,053
7,315
Directly from the Apple link I first posted:

Page outs occur when you have no free or inactive memory.

You don't have to reboot. If you close the apps that are placing high demands on memory, that memory will be freed up by Mac OS X, returning to either free or inactive memory, or both.

As I said before, the after picture shows that page outs occurred since the last restart, but does not prove that they occurred at a time when there was inactive memory available. I would be happy to concede that this is happening, but I've never seen any proof.

No no no. Look, I write software for living and I deal with garbage collection all the time.

Apple's support document is "dummied down" for average Joes. Inactive memory can mean many things. But it generally means one of two things.
  1. When you quit an app, its contents are first moved from active to inactive memory pool. If you re-run the app before inactive memory is reclaimed (and becoming free), it will be able to access them again.
  2. When app needs to access data from disk, and there's free memory, it is first transferred to inactive memory (into disk cache). Sometimes, OS X puts restriction on the cache size. But on modern OSes like Mountain Lion and newer versions of Linux, there's no limit ("free memory is wasted memory").
So what happens when you run out of inactive memory and app needs to create more object (write to memory)? If the data is in inactive memory (e.g., disk cache), all is well and it will be converted to active again. Otherwise, OS X will need to either release parts of inactive memory (and therefore making it available as free memory) or create virtual memory (which is disk being simulated as memory). The first part (reclaiming inactive to free) is a lot harder than it looks and doesn't happen as quickly as creating virtual memory.

Writing to virtual memory is called page outs and is much slower than writing to memory. Virtual memory is a series of very large files on /var/vm directory. Since multiple apps and processes can use virtual memory files, it is next to impossible to reclaim virtual memory without restarting your Mac. In other words, even when OS regains free memory, it will not move data from virtual memory to free memory.
 

GGJstudios

macrumors Westmere
May 16, 2008
44,545
943
When I have a bunch of inactive memory and no free memory, I get loads of pageouts and very poor performance.
It's this that I have never seen proven, regardless of user claims. I have never seen anyone prove that page outs occur at a time when inactive memory is available.
Inactive memory can mean many things. But it generally means one of two things.
Thanks for the details, but I'm quite familiar with how memory management works. Nothing you've said proves paging out occurs when inactive memory is available, or that restarting your Mac is required to free up memory. I've heard such claims from several people, but zero proof.
 

Ledgem

macrumors 68020
Jan 18, 2008
2,034
924
Hawaii, USA
People don't seem to grasp the fact that the page outs reading is not a real-time indication that page outs are occurring now, but rather a historical accumulation of page outs that have happened in the past, since the last restart.
I believe you, but I think there's something weird with 10.8's memory handling. With OS X 10.7 and 6 GB of RAM, my memory usage would usually hit the 60%'s pretty quickly, and over the course of the week it would rise to 70%. This is all with normal usage - mostly email and web-browsing. Using Aperture or other media applications obviously pushes the RAM usage up farther and induces page outs.

When I installed OS X 10.8 on that same system, my memory usage would stick around the 40-50%'s. I thought that OS X 10.8 was just more memory-efficient, but I was getting page outs even with my normal day-to-day usage. They weren't so numerous as to cause a system slowdown, but they were greater in number than with OS X 10.7.

Now I'm using a system with 16 GB of RAM. My memory usage is typically well under 40% for day-to-day usage, yet I still build up a swap file and experience page outs. The swap file is pretty small and the page outs are much, much less in number compared to my old computer with 6 GB of RAM, but it strikes me as odd that I get any paging out at all when I'm not using anything particularly RAM-intensive, nor am I multitasking heavily. Paging out when RAM utilization is less than 50%? I don't remember having page outs like this under OS X 10.7, and definitely not under OS X 10.6 even when I had only 4 GB of RAM.
 

nutmac

macrumors 603
Mar 30, 2004
6,053
7,315
As I said before, the after picture shows that page outs occurred since the last restart, but does not prove that they occurred at a time when there was inactive memory available. I would be happy to concede that this is happening, but I've never seen any proof.

Before and after screenshots are less than 15 minutes of each other. All I did was regenerate preview images in Aperture. If inactive memory is indeed available for anyone, OS X should never create virtual memory (and thus increasing page out count) in the first place.
 

SecretNY

macrumors member
Jun 15, 2007
69
2
I updated yesterday to 10.8.2 and I'm on a 13" Macbook Pro 2011 with 8GB. I never used all the free memory but after the update my mac was running so slow I checked and I had 75MB of free memory and 4 GB of inactive? I think theres a problem...
 

Jenni8

macrumors member
Apr 27, 2011
87
0
CA
To me it's the programs' fault. Or at least I think. . .

I have a Mid 2011 iMac and I do experience problems with memory. Although I don't have loads of experience, I have personally determined it a software issue. Not an Apple software issue, but an issue with the program I am running.

Almost any program runs smooth and superb with the exception of Safari of course as it is a memory hog, although it seems to have improved with each update since Lion. I love Safari and will only open Chrome when something doesn't quite open right due to Flash. Urg.

Here is my point of where I'm going: What programs are you running when this memory issue occurs? Because the only time I have issues is when I run BOTH Lightroom and Photoshop at the same time. Not by themselves, but at the same time. It can get frustrating as it's easier for my workflow to have both open at the same time sometimes.

I already know I need more RAM to fix my issue as I have a TON of pics and that is the primary reason for my issues. I will eventually get more RAM as I've been ready to, I can't count how many times, as I only have 4gigs. When I do upgrade I will upgrade to at least 12. It's just that with all that is going on in my personal life, I'd rather spend money on food or life stuff as times are harder than when I got my Mac. I did help my issue my creating a new Library for Lightroom with only my more recent photos and that has helped a lot. But as I keep adding more it does get slower with taking all the RAM and then everything goes to a crawl. (Maybe I need a better setup of how much Cache I use, as I haven't found the magic number yet.)

I found the problem with most programs with taking up too much RAM depends solely on how much Cache I allow for certain programs. As I've adjusted things, things run smoother.

Now this is just my 2 cents as I am no expert or seasoned user. But that is at least my observation. Also when I first got my iMac, It did have Snow Leopard on it and Photoshop and Lightroom Did run slower with the older version, even though I had WAY less apps on at the time.

Now from any pro user, does what I just explained make sense? Or do I have it twisted? I'm still learning and I feel I know a great deal in the short time I've owned my Mac. Also when I do get somewhat frustrated for whatever reason, it's usually my fault for an issue, as I love to tinker with my system a lot to make it MINE, or I just remember the horror of a PC I owned before my iMac and then I relax, cause it's still a 1,000 times better.
 

Ledgem

macrumors 68020
Jan 18, 2008
2,034
924
Hawaii, USA
Now from any pro user, does what I just explained make sense? Or do I have it twisted? I'm still learning and I feel I know a great deal in the short time I've owned my Mac. Also when I do get somewhat frustrated for whatever reason, it's usually my fault for an issue, as I love to tinker with my system a lot to make it MINE, or I just remember the horror of a PC I owned before my iMac and then I relax, cause it's still a 1,000 times better.
Yes, what you've said is correct. Multimedia programs in particular will take up a lot of memory, just because that's the nature of multimedia editing. Most of those programs don't have a set limit. If what you're doing is very demanding, their memory usage will increase up to the system's maximum capacity to accomodate it.

The problem mentioned in this thread doesn't really deal with that, though. The operating system is responsible for managing the memory between programs. If the memory becomes full, the operating system will determine what's in there that isn't currently being used (or that was last touched the least recently), and then put it into a "page file" on the hard drive. This is what paging out is. When the paged out information is needed, it will be transferred from the hard drive to the memory. If the memory is still very full, then the operating system basically swaps things around: the next least-used thing in the memory is put into the swap file and is replaced with what the system needs. Alternately, if enough memory has been freed up, then no exchange is necessary: information goes from the hard drive to the memory, and that's it.

It's worth noting that involving the hard drive drastically slows things down. Thus, paging out is very undesirable.

The problem in this case is that the operating system is paging out even when there's a lot of free memory. In my case, for example, I may be using 7 GB of RAM, but I have 9 GB free. Despite this, the operating system will occasionally page out. In theory, there's no reason why it should be paging out under such circumstances.
 

twintin

macrumors 6502a
Aug 10, 2012
719
246
Sweden
Not sure why you keep saying they are the same when they are clearly not in situations I have expereinced, told you about, yet ignored when you keep posting the same info.

I think there may be some misconception regarding what Inactive memory is. Reading up on FreeBSD memory management it seems Inactive memory is either:

- memory recently released (clean);
- memory recently paged out (clean);
- or memory that has not been touched for a longer period (dirty).

Clean memory is indeed similar to free memory. Only reason it is kept as inactive is to be able to reclaim it faster in the event the system that most recently used it is restarted/awaked again. However, dirty inactive memory must first be paged out before it can be used and hence can be more expensive to use.

Basically, even with lot of inactive memory, depending on how much of it is dirty respectively clean you may or may not encounter lot of page outs (the man page states that purge flushes disk caches).

Since unixes like OS X, FreeBSD and Linux love to cache lot of I/O accesses to speed those accesses up (especially if you use a HDD) I can imagine that disk intensive applications with frequent read and writes may eventually hog the system due to lot of caches being used.

Since the purge command seems to resolve your issue, what I described above seems to be the most likely cause of your problem.

Personally, even after weeks of uptime I have never experienced any kind of extensive page outs, slow downs or other memory issues and that with Safari, Mail and some other apps constantly running. Since none of my apps are disk intensive I guess my system uses very few caches and those used are probably periodically flushed from time to time leaving me with lot of "free" memory.

Basically, I believe there is nothing wrong with the memory management. This is just how it is designed to work. As with all algorithms there are always trade offs made and hence no algorithm will work perfectly for every one all the time. What you have encountered is the trade off made by the memory management algorithm of OS X.

The memory management in OS X does not differ much from other unixes like FreeBSD and Linux and I'm sure you can find similar discussions in forums related to those unixes as well.

Does all this make sense to you ?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.