Plasma 5 Memory widget wrong

The Plasma 5 memory status widget I think reports wrong.

While it reports I am using 9,6GB out of 32GB the command free reports something else.


**mintaka:/ #** free -h
             total       used       free     shared    buffers     cached
Mem:           31G        18G        12G       2,5G       652M       8,3G
-/+ buffers/cache:       9,8G        21G
Swap:           0B         0B         0B

I started checking this out when my Eclipse IDE was reporting memory problems with “Unable to create new native thread”.
Also when this happens I started getting problems with my browser loading new tabs.

With 12GB free memory I should not be getting any problems, but that is a different discussion.

Why is the memory widget reporting my memory usage so much lower than free?
I would like my dashboard/desktop to give me accurate information about my system.

Have you set TMPFS for any purpose? (Maybe you just have put your /tmp into memory as tmpfs.) I think the usage of TMPFS is not counted in the normal “used” number.

But it still odd that you have no ram to use when free says it has 12G as free.

I suppose it doesn’t count the “buffers/cache”, which are not really in use, but will rather be freed as necessary by the kernel.

It’s good to know that TMPFS usage is counted in “buffers/cache” :slight_smile:

So, if I set a tmpfs for temporary use, like I put a large file in it, will it be freed by the kernel? If not, then that might be the reason the OP has no ram to use for this case.

I don’t think it is.
According to “man free”:

The displayed columns are:
...
       **shared** Memory  used (mostly) by tmpfs (Shmem in /proc/meminfo, avail-
              able on kernels 2.6.32, displayed as zero if not available)

       **buffers**
              Memory used by kernel buffers (Buffers in /proc/meminfo)

       **cached** Memory used by the page cache (Cached in /proc/meminfo)

So, if I set a tmpfs for temporary use, like I put a large file in it, will it be freed by the kernel? If not, then that might be the reason the OP has no ram to use for this case.

Of course the kernel does not automatically delete files in /tmp. You can setup systemd to do that regularly (or do it via a cron job), but cleaning tmp is not done in openSUSE by default. (if /tmp is a tmpfs, it will be clean on reboot anyway though)

I’m not sure whether the contents of a tmpfs would be swapped out, but that’s irrelevant in this case anyway, as there is no swap.

I don’t know this. But in fact, I have a temporary directory put into ram, using following statement in /etc/fstab,

tmpfs   /ztmp  tmpfs   rw,users,nodev,nosuid,size=12G  0 0

And here is the outputs of free -h before and after I put a 2GB file into that folder,

cnzhx@a:~> free -h
              total        used        free      shared  buff/cache   available
Mem:            23G        1.7G         19G        524M        1.9G         20G
Swap:          2.0G          0B        2.0G
cnzhx@a:~> free -h
              total        used        free      shared  buff/cache   available
Mem:            23G        1.7G         17G        2.5G        3.9G         18G
Swap:          2.0G          0B        2.0G

So this 2GB file is counted both in “shared” and “buff/cache”, and it’s also subtracted from “free”.

It’s good to know that the kernel will not automatically delete files in a manually set tmpfs directory :slight_smile: Other things doesn’t matter then :stuck_out_tongue:

Well, I am not sure about this, but what you describe doesn’t necessarily mean that the 2GB file in the tmpfs is actually counted in “buff/cache”.

Copying the file to the tmpfs may have increased the buffers the kernel uses (after all the whole file gets read and written), and they would be freed again if necessary in that case, but the 2GB usage would stay in “shared” (and the other columns) even then.

It must be that. Then #3 post of yours should solve the OP’s doubts, I think.