# How to increase memory usage



## Deleted member 9563 (Jul 11, 2016)

My main machine runs FreeBSD 10.1-RELEASE-p10 with a KDE DE. I just expanded from 8GB to 16GB RAM in the anticipation of having good use for it with my new interest in VirtualBox. Indeed, because of my heavy use of Firefox tabs, I can push the memory usage past 6GB and adding a couple of operating systems in VirtualBox can bring it up to over 9GB. But why is the OS not using the rest? It's there and free, so could be used for caching. Is there something I can configure to make sure the OS uses most of the memory all the time?


----------



## Maxnix (Jul 11, 2016)

I found some hints about adjusting the values of *vfs.bufspace*,* vfs.maxbufspace* and, in case, of *kern.maxbcache*:
https://lists.freebsd.org/pipermail/freebsd-performance/2012-August/004639.html
https://forum.nginx.org/read.php?2,237680,237710


----------



## SirDice (Jul 11, 2016)

That's a new one. Most people come here to complain FreeBSD is, in their view, using up all their memory. 

But yours apparently isn't using enough? Just keep it running for a couple of weeks. It takes time for the caches to fill up. But it's entirely possible there's so little to cache you're still left with a lot of memory left over.

You could, for example, set /tmp to use tmpfs(5). That will certainly increase memory usage. As you have quite some left over this will improve performance on temporary files as they will now come from a memory disk instead of a, relatively slow, physical disk.


----------



## drhowarddrfine (Jul 11, 2016)

What SirDice said. Programs will use as much memory as they need, especially browsers, and as much memory as they can get in most cases. Some will complain about them as being "memory hogs" or "bloat" when the reality is, if you give them a gigabyte, they'll take it, unless they don't need it.


----------



## Deleted member 9563 (Jul 12, 2016)

SirDice said:


> That's a new one. Most people come here to complain FreeBSD is, in their view, using up all their memory.



Well I paid for it, and since it's in my computer figured that I might as well use it for something. 



SirDice said:


> You could, for example, set /tmp to use tmpfs(5). That will certainly increase memory usage. As you have quite some left over this will improve performance on temporary files as they will now come from a memory disk instead of a, relatively slow, physical disk.



That seems like the way to go. Perhaps use tmpmfs()? I've never tried either so will have to do a bit of reading. I'm just surprised that FreeBSD doesn't already utilize all available RAM as a matter of basic OS efficiency.



drhowarddrfine said:


> What SirDice said. Programs will use as much memory as they need, especially browsers, and as much memory as they can get in most cases. Some will complain about them as being "memory hogs" or "bloat" when the reality is, if you give them a gigabyte, they'll take it, unless they don't need it.



Yes it's quite hilarious how some people complain about their memory being used despite the fact that it's useless if it isn't - which would seem logical. One wonders why they even put it in their machine. 

Anyway, if FreeBSD isn't going to use it all by default I guess tmpmfs() or tmpfs() is an excellent choice.


----------



## Murph (Jul 12, 2016)

OJ said:


> I'm just surprised that FreeBSD doesn't already utilize all available RAM as a matter of basic OS efficiency.



Other than issues with failing to recognise / support hardware properly (doesn't look like that was an issue here), it does use all RAM by default.

What it doesn't do is preemptively load stuff into RAM; something needs to happen in terms of system activity to cause it to get around to using all of the RAM, particularly on systems with fairly huge available RAM.  If RAM is sufficiently plentiful and the demands for memory are sufficiently low, it may never get around to using all of it or take a very long time to do so.

If you can provide a good implementation for /dev/crystal.ball, the kernel could use that spare RAM for things which have yet to happen.


----------



## kpa (Jul 12, 2016)

Pretty much what Murph said. There are predictive caching methods such as the one used by ZFS but even that requires some initial action that triggers the predictive read-ahead. Starting from a cold start the system has no way of knowing which parts of the OS are going to be needed and any guesses by programmatic methods are going to be wrong on average. It's better to leave parts of the memory unused until there is an actual user for that memory rather than try to be clever and overcommit too early only to be forced to downsize the caches or whatever the memory was allocated for.


----------



## fossette (Jul 12, 2016)

I automatically launch all the software that I usually use on startup, so that should be a hint to the OS.

;-Dominique.


----------

