# Memory leak



## Keshkins (Mar 31, 2009)

My server freebsd has growing Active memory. It fills all the 3Gb in a day, ps statistics by process show that processes all together take about 1Gb.

What could it be? Where does the memory go?

Version is 7.1 upgraded from 6.1 with compat6x.
Services: nginx,apache22,mysql41,php,perl,munin

Thanks in advance.


----------



## SirDice (Mar 31, 2009)

Do note that the free memory will get used for file caching.


----------



## DutchDaemon (Mar 31, 2009)

Do you ever run out of memory, or are you using a lot of swap? FreeBSD tends to reserve/preallocate almost all available memory, but it will always leave some free. For example, on a 1,25 GB RAM system, something like this is entirely normal:


```
Mem: 873M Active, 93M Inact, 241M Wired, 31M Cache, 112M Buf, 9232K Free
```

My system requires nowhere near this amount of RAM at the moment, but FreeBSD will just keep it 'under its wings'. Indeed, for caching purposes.


----------



## Keshkins (Mar 31, 2009)

Current state is 


```
up 0+16:15:17
Mem: 2461M Active, 649M Inact, 212M Wired, 127M Cache, 112M Buf, 59M Free
Swap: 4071M Total, 36K Used, 4071M Free
```

I haven't yet tested it for swap, i'll wait longer and make a post with results.


----------



## DutchDaemon (Mar 31, 2009)

This is entirely normal. Don't worry.


----------



## SirDice (Mar 31, 2009)

Keshkins said:
			
		

> I haven't yet tested it for swap, i'll wait longer and make a post with results.



You can keep an eye on it with the *vmstat* command.


----------



## Keshkins (Mar 31, 2009)

Thanks to everyone 
I am just a little bit paranoid 
When it reached 2,9 Gb, system transfered 1,5 G to inactive memory.
Swap was not even touched.


----------



## Djn (Mar 31, 2009)

On a random note, this closely mirrors some reactions to Vista. 
(It's better at using spare RAM for buffering than XP was, leading to exactly the same apparent issue.)


----------



## gordon@ (Apr 1, 2009)

Be aware that FreeBSD doesn't even start tracking active vs inactive memory until it actually needs to. If there are boat loads of free memory, it doesn't bother tracking it. When there is memory pressure, then it'll track, classify and finally swap.


----------



## Carpetsmoker (Apr 1, 2009)

Djn said:
			
		

> On a random note, this closely mirrors some reactions to Vista.
> (It's better at using spare RAM for buffering than XP was, leading to exactly the same apparent issue.)



I think it would be more correct to say that ``XP is absolutely horrible at managing RAM , and Vista is slightly better''
</OtRant>


----------

