WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Physical RAM Usage  (Read 2288 times)

Offline SamK

  • Hero Member
  • *****
  • Posts: 713
Physical RAM Usage
« 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:
  • Mem Total 514896K Used 137132K
  • Swap Total 369344K Used 0

Via top:
  • Mem Used 137236K

Via htop:
  • Mem Total 502MB Used 47MB
  • Swap Total 360MB Used 0

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:
  • Mem Total 514916K Used 33380K
  • Swap Total 128720K Used 0

Via top:
  • Mem Used 33400K

Via htop:
  • Mem Total 502MB Used 15MB
  • Swap Total 125MB Used 0


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?
 
« Last Edit: July 25, 2010, 05:55:59 AM by SamK »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11043
Re: Physical RAM Usage
« Reply #1 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.
« Last Edit: July 25, 2010, 06:21:43 AM by curaga »
The only barriers that can stop you are the ones you create yourself.

Offline SamK

  • Hero Member
  • *****
  • Posts: 713
Re: Physical RAM Usage
« Reply #2 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?
 

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11043
Re: Physical RAM Usage
« Reply #3 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.
The only barriers that can stop you are the ones you create yourself.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Physical RAM Usage
« Reply #4 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
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)