# A lot of memory without reason



## sk8harddiefast (Jan 25, 2012)

I have 16 Giga RAM on my computer. My computers now I am writing this post runs orage, vlc, xpad, chrome and mousepad. But my computer uses 78% of my RAM! What's going on?


```
[FILE][B]uname -a[/B][/FILE]
FreeBSD BSD|ZFS 9.0-RELEASE FreeBSD 9.0-RELEASE #1: Tue Jan 17 14:33:28 EET 2012     root@BSD|ZFS:/usr/obj/usr/src/sys/MYKERNEL  amd64
```


----------



## phoenix (Jan 25, 2012)

Search the forums for "free memory is wasted memory" for many threads on this subject.


----------



## wblock@ (Jan 25, 2012)

http://www.freebsd.org/doc/en_US.ISO8859-1/books/faq/book.html#TOP-FREEMEM


----------



## bbzz (Jan 26, 2012)

You are running ZFS. Most of your mem should be "wired".


----------



## sk8harddiefast (Jan 26, 2012)

I read this: http://www.freebsd.org/doc/en_US.ISO...ml#TOP-FREEMEM
I agree. Ok. But sometimes push it to the limits and my system start to hang! This should not happen! Ok for 70%, 80% but 97% ? And sometimes increasing very fast!
But also I read this section:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/faq/book.html#COMPATIBILITY-MEMORY
I use 16 GIGA and over 4 GIGA if understood right need PAE option on my kernel. My kernel has not this option. So I am going to add and recompile the kernel to see if there is any difference.
But if is this the problem how to add it?


> If you wish to create your own kernel configuration file, you can enable PAE by adding the following line to your configuration:




```
options       PAE
```
But

```
ember /usr/src $ sudo make buildkernel KERNCONF=MYKERNEL

--------------------------------------------------------------
>>> Kernel build for MYKERNEL started on Thu Jan 26 02:39:10 EET 2012
--------------------------------------------------------------
===> MYKERNEL
mkdir -p /usr/obj/usr/src/sys

--------------------------------------------------------------
>>> stage 1: configuring the kernel
--------------------------------------------------------------
cd /usr/src/sys/amd64/conf;  PATH=/usr/obj/usr/src/tmp/legacy/usr/sbin:/usr/obj/usr/src/tmp/legacy/usr/bin:/usr/obj/usr/src/tmp/legacy/usr/games:/usr/obj/usr/src/tmp/usr/sbin:/usr/obj/usr/src/tmp/usr/bin:/usr/obj/usr/src/tmp/usr/games:/sbin:/bin:/usr/sbin:/usr/bin  config  -d /usr/obj/usr/src/sys/MYKERNEL  /usr/src/sys/amd64/conf/MYKERNEL
/usr/src/sys/amd64/conf/MYKERNEL: unknown option "PAE"
*** Error code 1

Stop in /usr/src.
*** Error code 1

Stop in /usr/src.
```
Also not sure if is needed because I use 64 bit.
Ok. Now I start scratching my head :q


----------



## LateNiteTV (Jan 26, 2012)

PAE is only needed for i386.


----------



## sk8harddiefast (Jan 26, 2012)

Then why increasing and pushing to the limits? I am going to search on forum more careful!


----------



## UNIXgod (Jan 26, 2012)

sk8harddiefast said:
			
		

> Then why increasing and pushing to the limits? I am going to search on forum more careful!



Do you run zfs?

It will eventually use (almost) all your ram.


----------



## sk8harddiefast (Jan 26, 2012)

Yeap. I run ZFS.


> It will eventually use (almost) all your ram.


And this is normal?


----------



## gkontos (Jan 26, 2012)

Try disabling prefetch and limiting the ARC value to 3 quarters the size of your RAM. 

In /boot/loader.conf


```
vfs.zfs.prefetch_disable=1
vfs.zfs.arc_max="12288M"
```

In my desktop running 9-STABLE with 4G I don't need to do any tuning anymore. If you still don't see any improvement you can limit the ARC to half the size of your RAM.


----------



## kpa (Jan 26, 2012)

sk8harddiefast said:
			
		

> Yeap. I run ZFS.
> 
> And this is normal?



It is perfectly normal except that ZFS doesn't autotune too well with the size of ARC cache and it's possible that you run out of memory when the ARC cache grows too big. Do what gkontos suggested and limit the size of ARC cache with the vfs.zfs.arc_max tunable.

Otherwise it is what was said earlier, "free memory is wasted memory".


----------



## vertexSymphony (Jan 27, 2012)

sk8harddiefast said:
			
		

> Yeap. I run ZFS.
> 
> And this is normal?



Yeah, ZFS caches *very* aggressively ... always remember "free memory is wasted memory".
If you're not using it, and it can improve performance, the usage is more than welcome.

Of course, you can tune this behavior using the tunables that the others metioned regarding the use of prefetch and the min/max size of the arc (oh, and dedupe also affects memory consumption)

http://www.solarisinternals.com/wik...y_and_Dynamic_Reconfiguration_Recommendations

Read the best practices guide and evil tuning guide to have a slightly deep understanding of how ZFS works, and then you can search for FreeBSD-specific things.

Regards.

P.S â†’ If my memory doesn't fail, ZFS uses "wired" (not inactive as UFS does) for the ARC, in any case, you can read the stats from the sysctl or, if you want something more sweet to read, check sysutils/zfs-stats


----------



## sk8harddiefast (Jan 29, 2012)

@gkontos trick work for now. I see difference on memory. For now I close the thread as Solved. If something goes wrong on future I will back


----------

