Inactive memory

Discussion in 'Mac Basics and Help' started by jer446, Oct 17, 2005.

  1. jer446 macrumors 6502a

    Joined:
    Dec 28, 2004
    #1
    I have 1.5gb of ram in my iMac 20 inch g5. I never looked before, but i checked out the activity monitor, and it said i had 528mb of inactive ram. What does this mean? Is this wasted or something? I have like 2 or 3 programs running and i only have about half of my ram free because of this inactive ram..
     
  2. wordmunger macrumors 603

    wordmunger

    Joined:
    Sep 3, 2003
    Location:
    North Carolina
    #2
    Run 10 or 15 programs and see how much inactive memory you have...
     
  3. Demon Hunter macrumors 68020

    Joined:
    Mar 30, 2004
    #3
    I think "inactive" just means that you used some RAM, and since there is no demand for that RAM from other applications, the data stays there until it's needed.
     
  4. iEdd macrumors 68000

    iEdd

    Joined:
    Aug 8, 2005
    Location:
    Australia
    #4
    What's the difference between "Free" and "inactive" RAM? Is it just that Free is loaded and ready or something?
    Here's a screenshot of activity monitor in this pismo (in sig) running tiger. It really needs more ram. Look at the amount of pageouts :D It beachballs so much. Are pageouts just when you run out of RAM in a way?
    I'm going to try and add 256 or 512 RAM soon...
     

    Attached Files:

  5. mrichmon macrumors 6502a

    Joined:
    Jun 17, 2003
    #5
    It does not mean it is wasted. The inactive RAM is the RAM that is allocated to applications that are inactive. That is the applications that are currently loaded in the system but are waiting for some external event to happen.

    For example, OS X has a program called the crashreporter daemon. This program detects when an application has crashed and collects information that can help apple determine why it crashed and fix the bug in a future release. There are also processes that deal with operating system and network services which only wake up when they have some work to do.

    The inactive programs generally have been swapped out to the pagefile but are ready to be swapped back in when they have work to do. Since the inactive pages have been copied out to the pagefile the inactive pages could be assigned to another program without loosing the contents of the inactive pages. But if no other programs need the inactive pages then the contents of the pages will remain in physical memory until the inactive program wakes up. Since the pages are still in physical memory the OS can avoid copying them back from the pagefile.

    A free memory page is one that has not been allocated to a program and is available to be allocated to a program. An inactive page has been allocated to a program but since that program is inactive and the page has been swapped out to the page file the inactive page is available to be allocated to another program that requests some memory. They are not moved to the list of free pages because the OS can potentially save some work later if the OS remembers that the page still contains the values from the inactive program.

    A wired page is a memory page that cannot be swapped out to the pagefile. Often these are core OS pages or pages that are shared between programs to enable programs to communicate with each other.

    To interpret the memory statistics, it doesn't matter how many programs you have running, what matters is how much memory each program needs. In many cases this depends on what you are doing with the programs. In general, don't worry about the figures since they are just giving an indication of some complex parts of the system.

    If you are interested in really understanding these things read up on "Virtual Memory" to get an understanding of memory systems and paging.
     
  6. Makosuke macrumors 603

    Joined:
    Aug 15, 2001
    Location:
    The Cool Part of CA, USA
    #6
    I'm sorry, but so far as I've ever read, this is just plain wrong. You're loosely describing how paging and virtual memory work, not OSX's Inactive RAM.

    The actual answer, and this is backed up by a (rather minimal) support page at Apple's site:

    http://docs.info.apple.com/article.html?artnum=107918

    ...is this: Incative memory is, basically, information that has been loaded into memory and marked as "no longer necessary", but is being kept around by the OS just in case it's needed again.

    So, if you open a hypothetical application, it loads 100MB of its stuff into RAM. That RAM is now in use. You then quit it. That 100MB is no longer in use, but instead of just throwing it out completely, OSX keeps that data in RAM in case you open the same program again. If you do, less loading from disk is necessary, so the application opens faster. If, on the other hand, that RAM is needed for something else (you open a different program and there's no more free RAM left), then it gets (instantly) thrown out in favor of the new data.

    So basically Inactive RAM is a normal function of the OS, can for most purposes be considered to be just like Free RAM, except a little better because it might get used again.

    This question is asked so frequently that there really should be a sticky or something with a concice explanation...
     
  7. mrichmon macrumors 6502a

    Joined:
    Jun 17, 2003
    #7
    Your hypothetical case is not feasible since the OS has no way of knowing what data the application is loading into memory that the application has allocated. The only way this scenario works is for shared libraries, program text segments and other static code loaded by the OS, not data loaded by the application. You hint at this when you say "so the application loads faster" but never actually say it. If you are going to get snotty about imprecise answers, get your own house in order.

    Yes, I gave a vauge and not very precise brush over page-based virtual memory in order to explain a vauge question that is directly related to paging. I did not explain program text loading optimization since I felt the secondary case of inactive pages due to swapped out pages was an example that would be easier for someone without exposure to OS principles to understand.

    According to this page, "The inactive list contains pages that are currently resident in physical memory but have not been accessed recently. These pages contain valid data but may be released from memory at any time." This implies that the common swap-in optimization of avoiding the disk access for inactive pages is valid in the OS X model.
     
  8. slooksterPSV macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #8
    I believe in some sense both of you are correct. If you open up a terminal prompt and type in top you can watch your memory status change. Ok I just did that on mine. I had 59MB in inactive memory. I opened up System Preferences and it changed to 61.4MB opened Accounts, that put it up to 69.7MB deleted an account, that pushed it up to 70.1MB. Exited accounts, it put it back to 61.2MB closed out and it returned it to 59MB.

    Basically it loads the basics of the program, and whatever variables aren't being changed it puts into inactive memory. When the user quits that application, that memory is flushed. Example:
    Code:
    int usrID = GetCurrentUserID();
    char *name;
    int userID;
    bool selection = false;
    ...//Add memory allocation here
    if(Selection(usrID, "Accounts") && !LockedProperties()){
    char[] x = GetUserArray(name, userID, usrID);
    }
    ...//Release memory if user quits current action
    
    Now that isn't the actual code, its just kind of what may or may not happen.
    What this could do is, it gets your current UID and sets it as usrID, you setup a variable for the name, userID, and if the user has made a selection selection. You can add memory allocation routines where ...///Add... is then it says IF the selection by the current user (marked as usrID) is Accounts and that returns true and the properties are not locked (! = is not) !LockedProperties then setup an array to get a list of User Names, the UID, from the current user.

    Now that's complex, so if you don't understand it, don't worry about it. It's just an example of how things may or may not happen.
     
  9. Makosuke macrumors 603

    Joined:
    Aug 15, 2001
    Location:
    The Cool Part of CA, USA
    #9
    I apologize, mrichmon, if I came across as being unpleasant; I've given or seen given some variation of the explanation I gave dozens of times here and elsewhere and never noticed it being corrected, so I incorrectly assumed that it was largely accurate. After reading through the document you referenced (which doesn't give a terribly detailed explanation of exactly how a page is marked inactive), I can see that I'm off on how Inactive memory works.

    That said, my thinking that you were wrong was based on your emphasis on sleeping daemons or the like as the source of inactive memory; the more substantive explanation you gave later looks to match exactly with Apple's tech docs, but my reasoning was that there must be some more precice criteria than just a sleeping process to get a page marked inactive or the inactive memory count wouldn't usually increase by much after startup.


    I'm now very curious as to what the more specific criteria for a page being marked inactive is, as this question gets asked a lot and I'd like to have a reasonably simple to explain but still essentially correct answer to offer.

    The documents referenced by both of us don't give enough detail; they both just say in essence "memory that hasn't been accessed recently", but it can't be that simple as the inactive size can change drastically upward as soon as you open or close an application, and if it were just residence time (or something "sleeping") it wouldn't account for that.

    For example, launching Word on a just-restarted system results in 12MB of additional Active memory, as well as 37MB of new Inactive memory, while quitting it reduces Active memory by 5MB and Inactive by 10MB; FireFox adds 22MB of Active of which 4MB seems to be released on quit and 37MB of Inactive of which 14MB is released to free on quit.

    Some of this, I'm assuming (as you mentioned and I was being intentionally vague about) is shared code of some sort being loaded into memory and not removed, but the fact that Inactive count changes immediately sort of implies that the app (or OS) can specifically mark a page as inactive but still resident. If either was only capable of completely destroying the page in memory, that RAM would immediately go back to being Free; if it was time-related, then it wouldn't happen immediately; if it was based on some sort of wait state, it should all disappear on quit when any waiting threads are terminated.

    Perhaps I'm misunderstanding something fundamental about how memory is allocated and all of that RAM is accounted for by threads internal to those applications waiting on input, but then I don't see why all of it woudldn't be released on quit. Is it mostly shared code that is just marked inactive after the app releases it?

    Since you seem to have a much firmer grasp on the concepts than I, I'd really appreciate if you (or slooksterPSV; I appreciate the attempt to help, but although I follow your pseudo-code it's not helping me understand this particular situation any better) could give me a more detailed explanation.
     
  10. StokeLee macrumors 6502

    StokeLee

    Joined:
    May 30, 2005
    Location:
    Stoke-on-Trent. Midlands, UK
    #10
    At this moment in time, these apps are open

    Mail
    Safari
    Msn Messenger
    and EyeTv

    Ive got 11mb free ram, now if i close EyeTv then it goes up to 500/600mb with the difference being inactive until i close EyeTv. I must admit ive not noticed any difference opening any other programs, some times ive got iTunes toast, and about 8/9 mounted CD's open, but still the same till i quit EyeTv.
     
  11. slooksterPSV macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #11
    EyeTV isn't only costly on RAM but your wallet too.
     
  12. StokeLee macrumors 6502

    StokeLee

    Joined:
    May 30, 2005
    Location:
    Stoke-on-Trent. Midlands, UK
    #12

    I hope you mean the initial outlay of buying it. :eek:
     
  13. slooksterPSV macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #13
    Oh yeah. Sorry, but yeah the initial items and that. I can watch TV on my Mac if I had all the connectors and that, wouldn't need EyeTV, could probably just use iMovie???
     

Share This Page