Solved Kernel uses a lot of RAM

Hello, All.

I have a questions:
  1. What kernel subsystem uses a lot of memory?
  2. How to avoid it?
  3. How to limit the memory for the kernel?
  4. Why uses vm.kmem_size_max="18G" and Wired="23G"?
Code:
# top
last pid: 44881;  load averages:  0.65,  0.73,  0.78    up 8+05:42:36  10:00:32
207 processes: 1 running, 206 sleeping
CPU:     % user,     % nice,     % system,     % interrupt,     % idle
Mem: 488M Active, 9828M Inact, 23G Wired, 8356K Cache, 29G Free
ARC: 16G Total, 2176M MFU, 9662M MRU, 5394K Anon, 2505M Header, 2280M Other
Swap:
***

# uname -a
FreeBSD anonymous 10.1-RELEASE-p16 FreeBSD 10.1-RELEASE-p16 #0: Tue Jul 28 12:04:19 UTC 2015     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64

# cat /boot/loader.conf
zfs_load="YES"
vfs.root.mountfrom="zfs:tank/root"
mfip_load="YES"
vmm_load="YES"
nmdm_load="YES"
if_bridge_load="YES"
if_tap_load="YES"
aio_load="YES"
cc_htcp_load="YES"
coretemp_load="YES"
accf_data_load="YES"
accf_http_load="YES"
accf_dns_load="YES"
loader_logo="orb"

vm.kmem_size="18G"
vm.kmem_size_max="18G"

kern.ipc.semmni="2048"
kern.ipc.semmns="512"
kern.ipc.semmnu="256"
kern.ipc.shmseg="2048"
kern.ipc.shm_use_phys=1
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gpt.enable="1"
kern.geom.label.gptid.enable="0"
vfs.zfs.prefetch_disable="1"
vfs.zfs.txg.timeout="5"
vfs.zfs.arc_min="1G"
vfs.zfs.arc_max="16G"
vfs.zfs.arc_meta_limit="8G"
vfs.zfs.vol.mode="2"
vfs.zfs.l2arc_noprefetch="1"
hw.igb.txd="2048"
hw.igb.rxd="2048"
hw.igb.rx_process_limit="-1"
hw.igb.enable_aim="1"
hw.igb.max_interrupt_rate="32000"
net.inet.tcp.syncache.hashsize="1024"
net.inet.tcp.hostcache.cachelimit="0"
net.link.ifqmaxlen="128"
kern.features.inet6="0"

# cat /etc/sysctl.conf
vfs.zfs.min_auto_ashift=12
vfs.zfs.l2arc_write_boost=268435456
vfs.zfs.l2arc_write_max=268435456
security.jail.sysvipc_allowed=1
security.jail.allow_raw_sockets=1
security.bsd.unprivileged_read_msgbuf=0
kern.ipc.somaxconn=4096
net.inet.ip.forwarding=1
kern.ipc.maxsockbuf=4194304
net.inet.tcp.sendbuf_max=4194304
net.inet.tcp.recvbuf_max=4194304
net.inet.tcp.cc.algorithm=htcp
net.inet.tcp.cc.htcp.adaptive_backoff=1
net.inet.tcp.cc.htcp.rtt_scaling=1
#kern.ipc.soacceptqueue=1024
net.inet.tcp.mssdflt=1460
net.inet.tcp.minmss=1300
net.inet.tcp.rfc1323=1
net.inet.tcp.rfc3390=1
net.inet.tcp.sack.enable=1
net.inet.tcp.tso=0
net.inet.tcp.nolocaltimewait=1
net.inet.tcp.experimental.initcwnd10=1
net.inet.tcp.syncache.rexmtlimit=0
net.inet.ip.rtexpire=2
net.inet.ip.rtminexpire=2
net.inet.tcp.syncookies=0
dev.igb.0.fc=0
dev.igb.1.fc=0
#dev.igb.2.fc=0
#dev.igb.3.fc=0
net.link.tap.user_open=1
net.link.tap.up_on_open=1
net.inet6.ip6.auto_linklocal=0
Here are vmstat -m and vmstat -z outputs
http://pastebin.com/raw.php?i=MG2s82fg

Please help me.
--
Vladimir Laskov
samflanker@gmail.com
 
You have 16GBs of memory used by the ARC cache, that should be clue where the memory is going. Don't touch vm.kmem_size_max unless you really know what you're doing, it's does not set a maximum for used memory (at least not directly) as you would think.

Overall there's very little tuning you need to do on amd64 on average use except for one tunable and that is vfs.zfs.arc_max that sets the upper limit for the size of ARC cache.
 
Back
Top