1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Inactive Memory vs. Free Memory

Discussion in 'General' started by dordal, Nov 22, 2009.

  1. dordal

    dordal New Member

    Messages:
    11
    Likes Received:
    0
    We have a couple of boxes running; top perpetually looks like this:

    Code:
    last pid: 66910;  load averages:  0.02,  0.11,  0.07   up 17+13:35:30  10:21:28
    80 processes:  2 running, 78 sleeping
    CPU:  1.6% user,  0.0% nice,  3.1% system,  3.5% interrupt, 91.8% idle
    Mem: 62M Active, 2813M Inact, 223M Wired, 151M Cache, 112M Buf, 4668K Free
    Swap: 28G Total, 92K Used, 28G Free
    Roughly ~80 -> ~100 processes, low load average, but only 4668K of Free Mem. Is this normal? My understanding is that Inact memory is basically the same as free memory.... so why doesn't FBSD clear that out? If a proc needed say, 10GB of memory at this point, does it ask the system to clear some Inact memory and then wait for that to be done?
     
  2. graudeejs

    graudeejs Member

    Messages:
    4,594
    Likes Received:
    0
    FreeBSD only clears memory when it needs to, till then it keeps all kind of cache.

    It's nomral (especially if you use UFS)
     
  3. Beastie

    Beastie Member

    Messages:
    1,917
    Likes Received:
    3
    Free memory is wasted memory -- an old BSD Unix saying.

    So yes, with an uptime of 17.5 days, 4MBs of free memory is quite normal.

    Free memory is memory that has *never* been used.
    In inactive memory you may have clean or dirty pages. Dirty pages are no longer in use, may be removed in the near future (after being synced to disk) and reallocated for something else.
     
  4. dordal

    dordal New Member

    Messages:
    11
    Likes Received:
    0
    Interesting. Just out of curiosity, what does UFS have to do with it?
     
  5. graudeejs

    graudeejs Member

    Messages:
    4,594
    Likes Received:
    0
    A lot.
    It uses a lot of memory for caching (that can be freed at any time)

    I remember when I was using UFS I had about 45MB free after some time of using PC.

    Now with zfs it's a different story. Most of time I have about 1.5G
    This doesn't mean that UFS was memory hungry, in fact, it's zfs that's memory hungry, they just work differently.

    I think it's also like this because of UFS_DIRHASH enabled in kernel :)
    But that is my guess.
    Well this is all i know
     
  6. robbak

    robbak New Member

    Messages:
    62
    Likes Received:
    0
    You'll probably find that at least some of that inactive memory has already been mirrored in swap, so that it is immediately available if a large request is made.

    You can be sure that the kernel is in a great position to free up heaps of memory very fast if a program requests it. Here's an exercise: Set up a fork bomb and see how quickly it grows!