Need Help Understand Apple Memory Usage

Discussion in 'MacBook Pro' started by nim6us, Jul 27, 2013.

  1. nim6us macrumors member

    nim6us

    Joined:
    Nov 20, 2012
    #1
    I'm new to Apple and I'm trying to understand how my Macbook is using memory. I have 4GB it says I'm using 3.91GB but 1.41GB is inactive. If it's inactive, doesn't that mean it's not being used? It says I only have 88MB free, so that leads me to think I need to upgrade my memory. I'm just concerned that if I do it will say I'm using 7.91GB and 5.41GB is inactive because the inactive memory is queued just waiting to be used.

    [​IMG]

    So what does inactive mean, and if these are my normal stats should I upgrade my memory to 8GB?
     
  2. Laco macrumors 6502

    Joined:
    Apr 23, 2008
    #2
    The main way to establish if you need more ram is to examine your pages out. If you have a lot then you will benefit from more ram. I had a lot and then I upgrade to 16 ram and now I have zero (byes) and my computer feels much faster.
     
  3. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #3
    Here is an explanation of the different memory readings you see.

    Below from the article:

    Laco is correct. The better indicator is do a reboot, then use the machine a few hours and check your pageouts. If you have a lot of pageouts, then you would very likely benefit from more memory.
     
  4. gr8tfly macrumors 603

    gr8tfly

    Joined:
    Oct 29, 2006
    Location:
    ~119W 34N
    #4
    Inactive memory works somewhat like a cache for previously allocated objects. If an application needs it again, it won't need to create it again (or, if you relaunch the app, it'll launch faster). However, if an application needs more RAM than is available as Free, then space can be reallocated out of the Inactive pool. So, in essence, Inactive is Free.

    Apple has this KB article on the subject: http://support.apple.com/kb/HT1342

    And, as others have mentioned, if you're not seeing appreciable page-outs, you probably have enough RAM for your purposes. It's page-outs that can slow the system down because they need to be read from mass storage (HD, SSD), which is much, much, slower than accessing RAM.
     
  5. throAU, Jul 27, 2013
    Last edited: Jul 27, 2013

    throAU macrumors 601

    throAU

    Joined:
    Feb 13, 2012
    Location:
    Perth, Western Australia
    #5
    Memory on mac, the short version:

    • Active = your programs are running in this. active memory can and will be swapped (paged out) to disk if you run out of RAM
    • Inactive = OS X is keeping this memory around in case it needs it again - typically this is disk cache.
    • Free = unused memory. this won't be very much as OS X will use memory when it loads things from disk as cache (to avoid reading from disk all the time). I.e., even if you have 1 small program open, eventually all your free RAM will become inactive if the machine is running long enough because sooner or later spotlight will run an index and read a heap from disk.
    • Wired = this is memory that can not be swapped out - the OS has "locked" it so that it will stay in RAM

    Now... when your mac loads an app it will...

    • try to allocate from FREE memory
    • if there is no FREE memory left, it will reclaim some of the inactive memory and use that (inactive memory = essentially "free")
    • if there is no inactive memory left, it will swap something out of active memory (page out)

    Now, things may get paged out occasionally. A page out number isn't necessarily terrible, the thing to do is to use your mac. If it starts getting slow, look in activity monitor and check the page out RATE. If it is paging a lot, right at that moment, it is an indication that you ran out of memory and the machine is slow because of that. This is a situation where you could DEFINITELY benefit from more RAM.

    However, you will benefit from more ram even if you aren't running out - why?

    Because the bigger the INACTIVE memory can be, the more parts of the disk that OS X can keep in memory after it has read the object from disk once, so it won't need to keep reading from disk as much. Reading from disk is very slow compared to RAM (especially if it is not an SSD), so even if you aren't getting page outs, more ram can speed things up. Just nowhere near as much as if you are running out of inactive memory.

    However, adding more and more memory beyond say, a few gigs left over for inactive is a case of diminishing returns.


    Worth noting: in Mavericks, apple have changed the terminology to be more in line with other operating systems, instead of free, active, inactive you now have: app memory, file cache (used to be called inactive), wired and compressed. e.g.:

    [​IMG]
     
  6. nim6us thread starter macrumors member

    nim6us

    Joined:
    Nov 20, 2012
    #6
    Thank you all for the valuable information, in a lot of ways Apple's memory allocation makes good sense. However the one thing I'm still a little unclear on is page outs. I guess I can Google the nitty gritty details, but what is considered a high, or unacceptable page out rate?
     
  7. bobr1952 macrumors 68020

    bobr1952

    Joined:
    Jan 21, 2008
    Location:
    Melbourne, FL
    #7
    Probably the one thing missing from the stats you provided is how long your machine has been up--you do have quite a bit of page outs but if you have not rebooted in a few weeks or more--well then it is not so much. If you just rebooted recently and have that many page outs, then I would say yes, more memory would help.
     
  8. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #8
    Pageouts will occur when there is no system memory left, so the OS spools some data off the the drive. Ideally, you would want zero pageouts.

    That said, if you have done something on your machine that is very memory intensive (maybe a HUGE Photoshop edit) and it causes some slight pageouts, and this is not something you do all the time... it is probably not a reason to run out and buy more memory.

    On the other hand, if you reboot your machine to start fresh with no pageouts and just use it as your normally would all day and you have large GBs of pageouts, you would likely benefit from more RAM.

    There is no hard rule either way. Just a judgement call based on what is normal usage for you.
     
  9. thundersteele macrumors 68030

    Joined:
    Oct 19, 2011
    Location:
    Switzerland
    #9
    With 3.4 GB swap in use, and page ins being lower than page outs, I believe the OP would benefit from more RAM.


    As comparison, my MBP with 8 GB of RAM has been running for 8 days now. I have 200 GB page ins, 10 GB page outs, and 1.17 GB swap used. I probably wouldn't notice any benefit from upgrading further, although I also benefit from having a SSD, so swapping is much faster.
     
  10. br3nt, Jul 28, 2013
    Last edited: Jul 29, 2013

    br3nt macrumors member

    Joined:
    Jul 1, 2012
    #10
    unfortunately the "inactive" RAM part is messy.
    What i've seen: OSX sucks at reclaiming inactive RAM and starts paging instead, even if I have like 4gb inactive.
    So the best thing one can do is try to reboot.
    (This is on a MBP retina with 16GB ram)

    The theory behind is it logical and good, but the implementation could be better, which i'm very sure we will see in the new OS (Mavericks) with how it handles RAM.

    Edit: added a pic :D
     

    Attached Files:

  11. nim6us thread starter macrumors member

    nim6us

    Joined:
    Nov 20, 2012
    #11
    So how many page outs is bad, or how do you gauge what is high?
     
  12. Yahooligan macrumors 6502a

    Yahooligan

    Joined:
    Aug 7, 2011
    Location:
    Illinois
    #12
    Well, a few things to note with what you posted...

    You've paged out (read "memory" from disk) more than you've paged in. This indicates that your system isn't just writing memory to disk because it's low, but it's reading that paged memory more than once because there's not enough memory to actually keep it loaded in memory.

    You're actively paging in (writing memory to disk), it wasn't just done in the past and now it's sitting on disk, the OS is actively trying to free up memory by paging what it can to disk.

    You've paged in AND out more than the total amount of memory your system has. That is bad. Quite bad.

    You're using nearly as much swap as you have physical memory.

    To answer your question about how many pageouts are bad or how to gauge, the lower the number of pageouts the better. My cMBP has been up for 3 days and has paged in 5GB but has paged out nothing and that is healthy. Paging out here and there is fine because there may come a point where you need to access data that was paged in, but you don't want to be actively paging in and out.

    You have 4GB memory, you've paged in/out 6GB, and you're using nearly 4GB of swap.

    Ok, so what's the difference between pageouts and swap?

    Essentially, it's the difference between writing application and cache memory to disk (page in) and taking an entire IDLE process and its memory and writing it to disk (swap in). Your OS has basically determined that your application usage adds up to nearly double your memory (real memory + swap) and that active processes need to have their memory paged in to and out from disk (pageins, pageouts).

    You haven't said what model Mac you have so it's hard to give a recommendation on what to upgrade to, however based on your memory usage I would recommend 16GB but even 8GB would be better than what you have now.

    I recommend 16GB, if possible, in order to keep as much loaded into memory as possible without going to disk. I'm simply looking at real + pageouts + swap = 14GB. Since you want to keep pageouts to a minimum, you're still looking at 10.6GB total memory (real + pageouts), so 12GB (8GB+4GB DIMMs) would also work for you, again if your hardware supports it, and you may still end up with idle processes being swapped out. I've disabled my swap file.

    Another thing to look at is your app usage. I don't know your level of experience/knowledge with OS X, though you do say that you're new to Apple, but some people don't realize that clicking the "X" on an app's window does not exit the app, it simply closes the window. The app will still be running. To actually quit the app you need to either press command-Q or click the app title in the menu bar and select "Quit..." If you're not doing this then every app you run remains running and eventually you end up with tons of apps using up memory and you don't realize it because they don't actually have a window open.

    Now, I'm not saying this is happening to you, you could very well be running memory-intensive apps and 4GB simply isn't near enough but it would be useful to both us as well as yourself to understand your usage habits; What apps are you running and are you indeed quitting the apps or are you simply closing their windows so that they continue to run and use memory?
     
  13. foxf8 macrumors member

    Joined:
    Jun 30, 2013
    #13
    i have 16gb of ram and after a day of usage no restart or anything i was at 13gb the first time i noticed i was freaking out i was like what is open that is taking 13gb and i did close everything. i was like is there a virus or what is open thats taking all this memory? in windows that be a sign something is up! but mac os doesn't operate like windows does, if u close something in windows its closed for good and your ram usage goes down right away. in mac os if u fully close something its half way closed so to speak. so if u where to open said program again later it well load faster next time. but in the mean time if u need more room and mac os is holding some of that program simi open it well then say ok u need room ill fully close this now and free up room. so its hard to judge if your actually full in mac os just because how it manages its memory for better performance. but its pretty cool if u think about it how it does it vs windows. also dont waste your money on those ram cleaners to free up ram its just the os doing its thing if u need more memory it well free up the memory its holding for standby incase u want to open a program again. its very weird coming from windows and actively watching your usage on windows to see it on mac being full or going up and up even tho u have fully closed everything.
     
  14. Yahooligan macrumors 6502a

    Yahooligan

    Joined:
    Aug 7, 2011
    Location:
    Illinois
    #14
    That is generally not accurate, Windows VM/memory management is different, but when you close an app in Windows it does not immediately free up any and all memory associated with that app. It will still cache the app as well as associated file data, if possible. So your statement isn't true. If you open Photoshop, edit a photo, then close Photoshop in Windows it will still be cached. If you were to go back a few seconds or even a few minutes later, assuming you haven't run something else that pushed the cached data out, and re-open Photoshop it would open much faster than the initial opening of the app...just like OS X.

    Again, that is false. There is no "semi-open" or "semi-closed", when you QUIT an app in OS X the app is gone, kaput, from the process list. Like Windows, OS X will cache the app and related file data until either something else needs that memory or the cached data becomes "dirty" and then the OS will work in reclaiming it.

    The only "semi-open" state as you would call it is if you only close the main WINDOW and don't actually QUIT the app, which is what I said before. If you only close the window the app is still running. There is no "semi" about it, it's open and running. Period. Only closing windows does not close the app. You may free up some memory by closing the window, but do not equate closing the window with fully closing, or even semi-closing, the app. That's not how it works.

    It's actually not difficult at all, the difficulty comes with not understanding what you're reading when looking at memory info and usage. OS X is really not much more than a pretty UI on top of Apple-modified open-source BSD Unix. The memory stats and usage info is not unique to OS X.

    I don't think you really understand memory or process management by either OS, unfortunately. That you think there is a "semi" and "fully" closed app state in OS X tells me that you have been looking at how resource utilization changes, but don't really understand what's going on behind the scenes or are making assumptions about it.

    I truly do hope you don't equate closing the windows (Clicking the "X" or pressing command-W) with closing the app and that everything "closed" means the app is now "semi-closed"...or "fully" closed...or who knows, because you're confused and your post comes across as confused and confusing. :)

    Using MS Outlook as an example, it's using 212.9MB of real memory in its current state.

    If I close the one and only window open, the main one, memory usage drops to 190MB. Is this what you are considering "semi" whatever? If so then that is incorrect. The app is still fully open. If I click the Outlook icon on the dock, poof the main window opens right back up again instantly. Why? Because the app was never closed so it never had to re-open, re-read the database, re-allocate the initial stack, etc.

    To be clear, closing windows is not exiting or quitting the app or putting it into some semi-closed state. If all you do is close windows then you will have "oh crap, what's going on?" moments because you are not properly exiting out of applications when you are done.
     
  15. foxf8, Jul 30, 2013
    Last edited: Jul 30, 2013

    foxf8 macrumors member

    Joined:
    Jun 30, 2013
    #15
    yes i fully quit my programs. thats how it was explained how it works on mac os to me. then do correct me how is it after a day of use 8+ hrs does my rMBP idle at 10+gb of ram usage when everything is fully closed or quitted.
     
  16. Yahooligan, Jul 30, 2013
    Last edited: Jul 30, 2013

    Yahooligan macrumors 6502a

    Yahooligan

    Joined:
    Aug 7, 2011
    Location:
    Illinois
    #16
    Easy, it's called cache. There's filesystem cache, app data cache, network buffers, etc. No OS, not Windows, not OS X, not Linux...none of them fully release memory back as "free" once the associated app is closed. That's part of the memory management, spending the time to go through and release that memory back as "free" memory wastes cycles when just letting it sit in cache doesn't waste anything. If an app needs the memory THEN the OS will reclaim some memory from cache/buffers and use it. Likewise, if you end up re-opening a file or an app that was accessed recently then you reduce physical I/O because it doesn't have to go back to disk, which is slower.

    Not to over-simplify things, but "free" memory is truly wasted memory. An OS that is both memory efficient and performance oriented will leave virtually no "free" memory while also not paging out.

    If you have 16GB of memory and at no point does your "free" memory drop below 6GB then that is 6GB of wasted memory. It's not helping you, all it's doing is consuming power.

    If you want to find out how much of your memory is being used by disk/filesystem cache, close all the apps, open Terminal, and then type "sudo purge" and see what happens to your memory. That's only one area of cache being cleared out and does nothing for other cached data, such as the app/data that remains cached after the app is closed.

    I just did a purge and my "used" memory went from 8.52GB down to 7.21GB. That was just filesystem cache, nothing else, and I didn't even access any large file recently.

    I just created a large, multi-GB file and then deleted it, purged, and used memory dropped to 6.88GB...

    Cache, buffers, apps, filesystems...the algorithms for managing this data are actually rather complicated, which I'm sure you know.

    Without getting too deep into it, there's a lot more to memory than apps. Every network connection uses memory just to open, then there are TCP windows, read/write network buffers, kernel parameters that dictate what the window and buffer sizes can be...and that's just part of the network stack and how it relates to memory.

    Closing every app and expecting free/used memory numbers to return to what they were right after a reboot is not a reasonable or logical expectation with any OS, that's not how they're designed and that's not an efficient use of resources.
     
  17. foxf8, Jul 30, 2013
    Last edited: Jul 30, 2013

    foxf8 macrumors member

    Joined:
    Jun 30, 2013
    #17
    windows in all my years has never, never idled above 2-3gb after a day of use. mac os still holds data so in its most basic form to explain would u not say its still in some ways simi open after u quitted a program?
     
  18. Yahooligan macrumors 6502a

    Yahooligan

    Joined:
    Aug 7, 2011
    Location:
    Illinois
    #18
    I can tell you right now that my wife's Windows PC with 16GB of memory and all apps closed only has 8.9GB "free."

    When you looked at Windows memory usage, did you actually look at "Resource Monitor" or did you simply right-click on "My Computer", click Manage, click "Performance" and look at the "% committed bytes in use" and "Available Mbyes" ? Because I can tell you right now the latter method is over-simplified and does not tell you everything that "Resource Monitor" will. If I had no interest in knowing, or didn't know anything, about how memory management works then the "% committed" and "Available MBytes" screen would be sufficient as it is for probably 99% of Windows users, it's the "memory info for dummys."

    Open up "Resource Manager" and click the "Memory" tab if you want the REAL story. Wife's laptop is "idling" right now...8.9GB of 16GB free, over 4.6GB of that is "Standby" which is what Windows is calling cache. If you add the "Standby" (cache) and "Free" together then you get the same number as the "Available MBytes" in the Performance section of Computer Management.

    No, you need to get rid of this "semi" notion, it's just wrong and is making it harder for you to understand what's going on. An app is either open or it's closed, the exception to this is an app that has a client and background service process. A perfect example of this is CrashPlan, there is a background process that is always running, watching your files, tracking what needs to be backed up, backing up files, etc. Then there's the client, which itself is really a separate app but in this example we'll just say it's a component of the "CrashPlan package." The client is the UI that you interact with, the service is what actually does the work. Quitting the client doesn't stop the service. This is not a typical app, but a client/server app.

    Apps like Firefox, Photoshop, iPhoto, Mail, Diablo III...these are typical apps. When you run one it reads the app and data from disk into memory and it starts up, you use it, then when you QUIT the app it goes poof, it is no longer a part of the running system. It is not semi-closed, it is just downright closed, period. The OS will cache various bits of the app in case that data is accessed again before it gets replaced by other data/cache or reclaimed due to that part of the cache becoming "dirty." If you quit Firefox and then think, "Shoot, I forgot to check my email" so you open Firefox back up, bam it opens pretty quick, right? This is because it was still cached. You launched the app, the OS saw you were wanting to access files that exist in cache so it read the data from cache and avoided making physical I/O calls to read from disk, this increases performance and is also a more efficient use of resources, such as memory and disk I/O. The OS did not keep any part of the app open and running. This is not something OS X does differently than Windows, they BOTH do this.

    So, just toss the idea of "semi" anything out the window.
     
  19. foxf8 macrumors member

    Joined:
    Jun 30, 2013
    #19
    that whole thing in a nut shell is what i already said i just use different terminology. i say simi closed in case of re open. tho thats not the true whole story, that makes since to someone that has no idea whats going on. u say its closed fully and some of the files are then stored as cache the principle is the same tho your terminology is correct tho. just brings question to whats cache exactly? the way i word it there is no question the user has idea of whats going on. this was fun tho :)
     
  20. Yahooligan macrumors 6502a

    Yahooligan

    Joined:
    Aug 7, 2011
    Location:
    Illinois
    #20
    But wouldn't you rather teach them the correct terminology and functionality being used? Saying something is semi-closed says that part of the app is still running when it's not. Since you kept repeating your semi-closed wording it continued the back-and-forth of this thread because your wording doesn't explain what is happening but attempts to say something is happening that isn't. For someone trying to learn how things work that's going to be confusing to them and then they may end up using your terminology and cause the spread of confusion and/or misinformation. My hope was that helping you understand memory management would also help you use the correct terminology. :)

    The principle may be the same in your head, but your wording makes what we're saying very different. Perhaps it's a language barrier. When you quit an app then it closes everything. There is nothing actually "open" anymore, the OS simply holds various parts of the app/data in memory in case it's needed again, this doesn't prevent anything from using that memory as the OS will easily give it up if needed, it's not locked memory.

    Think of cache as a helper when you're working on a car. You ask the helper for a 10mm socket so they go to the toolbox and get a 10mm socket and give it to you, you use it and then hand it back to the helper when you're done. At this point, which would be a more efficient use of the helper and toolbox...

    - Helper holds the socket at the ready for you should you need it again
    - Helper walks back to the toolbox and puts the socket away, then returns to your side waiting for your next request

    In the first scenario you'd have the 10mm socket back in your hands right away. If you needed an 8mm socket instead then the helper would just return the 10mm to the toolbox and bring the 8mm back. That only takes one round-trip and you have to wait a little longer.

    In the second scenario if you wanted the 10mm socket back then the helper would have to take another trip back to the toolbox and get it all over again, which makes you wait, makes the helper work harder, and adds to the toolbox's wear.

    That's an oversimplified example of cache, but should give you an idea of what purpose cache has and why completely freeing up cache when something closes is not efficient.

    The way you word it is not an accurate idea of what is going on, so it's not really helping the users except to give them incorrect info.

    Well hey, as long as someone learned something then it's all good.
     
  21. foxf8, Jul 30, 2013
    Last edited: Jul 30, 2013

    foxf8 macrumors member

    Joined:
    Jun 30, 2013
    #21
    i hope u did. your since of having to have things a certain way is interesting. your personality is definitely a strong ISTJ or INTJ. there is no language barrier your personality just has to have things in a certain way and u expect others to do the same. your refusal to agree or even see that if an app closed and yet the os still has some traces of it in cache can still be considered open? until its re claimed and thus fully closed. i wonder which way of explaining well grandma learn faster? the point is not to win but teach someone :) your just more interested in facts and details, i just want to get the point across so theres no wining between us lol
     
  22. Yahooligan macrumors 6502a

    Yahooligan

    Joined:
    Aug 7, 2011
    Location:
    Illinois
    #22
    Ok...yes, I learned that you're not interested in learning how things really work and would rather go on with your made-up terminology and assumptions. That's fine, I'd just feel bad if someone were to learn that from you and end up in a situation where they end up made to feel like an idiot when they tried to have this same conversation with someone that's not quite so nice/friendly. :)

    We are talking about technical functions with official names that do specific things. Forgive me for trying to help someone be able to have a discussion where the the terminology is important. Maybe I should've just said "Well, the thingy holds the doohickey in suspension should the whoozit wonky do." Why" Because that would've made perfect sense to me, but good luck getting you to understand it. Hopefully you can see my perspective instead of trying to analyze my personality as you, honestly, don't know me.

    I never said I didn't understand what you're saying, simply that what you're saying about something being still open is simply not correct on a technical level. You want to say I have a problem refusing to agree? Sorry, you have a problem with your unwillingness to accept you are using wrong and confusing terminology. This is not on me.

    Open and closed in terms of something being in cache or removed from cache is just fundamentally incorrect. Excuse me for trying to help you be able to speak about this in an educated manner. I'll simply leave you to your own world where it's ok to just make things up.

    Why would a grandmother care to learn about the inner workings of an operating system's memory management...

    Wait a minute, I'm more interested in facts and details when someone is asking questions about how something works? Shame on me. I should've just made it all up and used random words, apparently. :rolleyes:

    Have a nice day, I think we're done here.
     
  23. foxf8 macrumors member

    Joined:
    Jun 30, 2013
    #23
    yeah unfortunately we are. but see how you pick apart everything i say, details details lol its the idea man!!! i dont mean to troll u now but wow im laughing so hard lol
     
  24. laurihoefs, Jul 30, 2013
    Last edited: Jul 30, 2013

    laurihoefs macrumors 6502a

    laurihoefs

    Joined:
    Mar 1, 2013
    #24
    Hey yeah, don't let any facts get on your way!

    Seriously though, the term semi-open just is quite misleading and not very descriptive. I'll take one (and only one, don't worry) shot at explaining it to you with an analogy. Let's pretend, that a cat can be in three possible places: on your lap, on the table, and outdoors. But instead of saying it is outdoors we now say, that it is semi-on-your-lap or semi-on-the-table. How on earth does that make the cats whereabouts one bit clearer?
     
  25. foxf8 macrumors member

    Joined:
    Jun 30, 2013
    #25
    nice one but in this case the cat "data" never leaves your lap it just went to sleep. and if another cat wants to sit on your lap u have to make room for new one. or wake up the original if u want to pet it again :)
     

Share This Page