# Inactive Memory vs. Free Memory



## dordal (Nov 22, 2009)

We have a couple of boxes running; top perpetually looks like this:


```
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?


----------



## graudeejs (Nov 22, 2009)

FreeBSD only clears memory when it needs to, till then it keeps all kind of cache.

It's nomral (especially if you use UFS)


----------



## Beastie (Nov 22, 2009)

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.


----------



## dordal (Nov 23, 2009)

killasmurf86 said:
			
		

> It's nomral (especially if you use UFS)



Interesting. Just out of curiosity, what does UFS have to do with it?


----------



## graudeejs (Nov 23, 2009)

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


----------



## robbak (Nov 23, 2009)

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!


----------



## polv (Mar 23, 2021)

Thank you all very much. Now I understand the distribution of memory. Just I at busy memory 30G tried to write down there in memory disk 10G the file and received the hung system. Therefore, I thought that FreeBSD rests on some kind of restriction.


----------

