Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: SamK on July 25, 2010, 05:18:02 AM

Title: Physical RAM Usage
Post by: SamK on July 25, 2010, 05:18:02 AM
What is the best way to determine the amount of physical RAM that is currently being used on a given machine?

On this PC it is reported as follows:

Via free:

Via top:

Via htop:

EDIT
I decided to repeat the tests in a clean environment as follows:
Booted TC in cloud mode
Boot options: base norestore noswap
Installed htop

Reports:
Via free:

Via top:

Via htop:


Does the compressed swap in RAM in TC3 affect the reports?  Does the option noswap affect the compressed swap in RAM? What is the amount of physical RAM used?
 
Title: Re: Physical RAM Usage
Post by: curaga on July 25, 2010, 06:17:46 AM
free & top do report all ram that's in use, but a part of it is caches that can be freed as necessary. These are not included in htop's number.

There are two things mixing things up a bit with regards to the caches, TC being in tmpfs (cache that can't be freed), and the compressed swap (takes ram, but less than the "swap used" number says; can be freed once there is free ram).

So if you want the exact hard number, use htop's + ~ 18mb (tinycore.gz unpacked) + ~(used ramzswap/2).
Plus any files stored in ram, such as browser settings and extensions in cloud mode.
There's a script to free all freeable caches, after which the number of free and top is correct:
Quote
sudo cache-clear


Quote
Does the option noswap affect the compressed swap in RAM?

No, it's usually desired even when the disk swap is unwanted. The embed code also disables ramzswap currently.
Title: Re: Physical RAM Usage
Post by: SamK on July 25, 2010, 07:18:01 AM
Thanks for the swift reply curaga.

If I understand correctly the easiest way to determine the RAM usage (in TC terms) is using cache-clear plus either free or top.

I am considering extending life of old thin-client machines by re-tasking as an appliance type device based on the local installation of TC and apps.  Some of these devices have memory modules soldered to the motherboard making them almost impossible to upgrade.  Knowing in advance the RAM required for a particular TC thin-client device is desirable.

So if you want the exact hard number, use htop's + ~ 18mb (tinycore.gz unpacked) + ~(used ramzswap/2).
Plus any files stored in ram, such as browser settings and extensions in cloud mode.
OK, I would like to learn a little more here.  I understand " ~ 18mb (tinycore.gz unpacked)."

Please will you expand further on these:

...+ ~(used ramzswap/2).
Is this the amount of swap reported by top divided by 2? Or is the default compressed swap always a fixed size (i.e 128MB) making the calculation [total amount of swap reported by top minus 128MB] divided by 2?

Plus any files stored in ram, such as browser settings and extensions in cloud mode.
How is this obtained/calculated?
 
Title: Re: Physical RAM Usage
Post by: curaga on July 25, 2010, 07:36:24 AM
If I understand correctly the easiest way to determine the RAM usage (in TC terms) is using cache-clear plus either free or top.

Yes

Quote
...+ ~(used ramzswap/2).
Is this the amount of swap reported by top divided by 2? Or is the default compressed swap always a fixed size (i.e 128MB) making the calculation [total amount of swap reported by top minus 128MB] divided by 2?

Amount of used swap in the ramzswap device, they can be seen per-device in /proc/swaps. Divide by 2 is an estimation of the zlib compression used. Size of the compressed swap is 25% of ram by default.

Quote
Plus any files stored in ram, such as browser settings and extensions in cloud mode.
How is this obtained/calculated?

du -hs /home
du -hs /tmp/tce

Of course the first goes away with a persistent home, and the second with a tce dir.
Title: Re: Physical RAM Usage
Post by: tinypoodle on July 25, 2010, 08:55:08 AM
to determine RAM size used as storage you can do:
Quote
df |grep tmpfs
so by deducting this number from total mem usage you get mem usage minus file storage (always after an instantly preceeding <sudo cache-clear>). If i understand right, tmpfs usage gets accounted
as cached mem(?)

The most detailed output of mem use is given by
Quote
cat /proc/meminfo

Another aspect to take into consideration might be Slab allocation which can gradually increase with system activity since last boot