# Wired memory growth



## aragats (Oct 6, 2016)

I observe a significant growth of the wired memory in a small VPS with 512MB RAM.
Right after booting top shows 34MB Wired, then after a couple of simple operations like installing a package or deleting a directory with large number of files it jumps to 190MB+:
	
	



```
Mem: 18M Active, 34M Inact, 192M Wired, 35M Buf, 222M Free
Swap: 1024M Total, 1024M Free
```
Initially I used FreeBSD 10.3 with root on zfs. I've found many reports about zfs memory usage, and I thought that's the reason.
Then I switched to FreeBSD 11 on UFS and see the same behavior.
The only service enabled is sshd.
Here is the output of vmstat(8):
vmstat -m
vmstat -z

Thanks for ideas and directions!


----------



## kpa (Oct 6, 2016)

Wired memory is memory that the kernel needs for various data structures for its crucial operations and can't be swapped out (hence "wired") because that would result in a deadlock. I don't see anything that would suggest a memory leak, to prove that there really is a memory leak you have to go pretty deep into the kernel debugging and gather the vmstat(8) results over a long period. 

You can also count on FreeBSD trying to use memory for filesystem buffering when free memory is available and that might just what you're seeing.


----------



## SirDice (Oct 6, 2016)

This is on a 4GB VPS after a couple of weeks of running:

```
Mem: 398M Active, 262M Inact, 3161M Wired, 6784K Cache, 138M Free
ARC: 2029M Total, 807M MFU, 263M MRU, 784K Anon, 65M Header, 893M Other
Swap: 2048M Total, 205M Used, 1843M Free, 9% Inuse
```

Nothing out of the ordinary.


----------



## aragats (Oct 6, 2016)

Well, I have a different example:
my router runs pfSense on FreeBSD 10.1-RELEASE-p4:

```
Mem: 9416K Active, 67M Inact, 68M Wired, 174M Buf, 1774M Free
Swap: 4096M Total, 4096M Free
```


----------



## kpa (Oct 6, 2016)

Is the router constantly starting new processes and accessing new files? I doubt that it is. A router usually has the services and kernel modules loaded at the start up and the memory usage shoots up initially but then goes down when nothing new gets run in a while and levels down to constant low level when the parts of the memory that haven't been used in a while are purged and put to the inactive list.


----------



## kpa (Oct 6, 2016)

The point I'm trying to get across is that you can't judge the memory usage by just looking at the numbers and thinking that the numbers are too high for your taste, a modern operating system with modern memory management is way too complex to analyze with a quick glance even for the best of experts.


----------



## aragats (Oct 6, 2016)

I just want to make sure it is OK. Of course, I'll run this VPS for long time with a simple web site, DNS, sending/receiving mail, hosting Twilio stuff etc.
I never paid much attention to the wired memory in larger systems, e.g. my laptop shows about 4GB wired having 16GB RAM and running on zfs.


----------

