# managing memory in freebsd - inactive memory



## chrcol (Mar 7, 2010)

Hi

Ok if I understand correctly, the inactive memory reported in 'top' is memory that was used by previously loaded applications and is effectively cache sort of like prefetch in windows where it keeps their data cached incase they are used again.

Here is my top at the moment on this server.


```
last pid: 19377;  load averages:  0.29,  0.27,  0.27   up 155+07:21:18 17:15:26
144 processes: 1 running, 142 sleeping, 1 zombie
CPU: 17.7% user,  0.0% nice,  3.8% system,  0.0% interrupt, 78.6% idle
Mem: 291M Active, 387M Inact, 185M Wired, 25M Cache, 105M Buf, 44M Free
Swap: 2048M Total, 253M Used, 1795M Free, 12% Inuse
```

load average is ok, system responsiveness is ok as well.  However it seems to be favouring swapping data so it can preserve this cache, if I am misunderstanding this and inactive memory is actually used memory then ok.  This machine cannot get a ram upgrade at the moment due to financial constraints.

any thoughts on how to make it flush the inactive pages? or if I am misunderstanding it.


----------



## Alt (Mar 7, 2010)

There is no practical reason in having like 98% Free. Its better to use mem for caching, these Inact can be freed by kern any time it will needed


----------



## chrcol (Mar 8, 2010)

I dont want 98% free, but I would prefer it to flush inactive data instead of swapping new data.


----------



## Alt (Mar 8, 2010)

Its not bad when your swap 12% Inuse. Its bad when it swap in/out actively


----------



## chrcol (Mar 8, 2010)

ok thanks, from what I can see its not doing that so I think I am ok.


----------



## chrcol (Mar 12, 2010)

this is now solved, the main problem was someone was running a script every now and then making mysql demand many hundreds of meg on demand, since this was bursty memory usage it played havoc with the memory system.

I also set the following sysctl to make the system favour losing cache instead of swapping.


```
vm.defer_swapspace_pageouts=1
```

here new top stats


```
last pid: 86485;  load averages:  0.51,  0.26,  0.20   up 159+14:38:08 00:32:16
186 processes: 1 running, 185 sleeping
CPU: 17.7% user,  0.0% nice, 14.7% system,  0.4% interrupt, 67.3% idle
Mem: 293M Active, 375M Inact, 181M Wired, 26M Cache, 105M Buf, 45M Free
Swap: 2048M Total, 2048M Free
```


----------

