Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] top command: meaning of 'm' in memory related values?



On Sat, Feb 22, 2014 at 12:32 PM, Bruno Raoult <braoult@example.com> wrote:
Hi,


On Sat, Feb 22, 2014 at 9:02 AM, Raymond Wan <rwan.kyoto@example.com> wrote:
On Sat, Feb 22, 2014 at 7:47 AM, Jim Breen <jimbreen@example.com> wrote:
> I've always thought it meant "megabytes".
>
> The man page says "VIRT  --  Virtual Image (kb)", but I suspect
> it's out-of-date.


Yes and similarly, "g" means gigabytes.  I've seen that a before, too...

The manpage says "VIRT  --  Virtual Memory Size (KiB)"

I would think that all values in top are expressed in (SIC) "kibibytes (KiB), mebibytes (MiB) or gibibytes (GiB)" rather than kilo/mega/gigabytes.

I had a look on top source code, as I was not 100% sure of my guess...

From line 1064 of top.c is the confirmation of hard-coded values in base 2 units:

static const char *scale_num (unsigned long num, const int width, const int type) {
      // kilobytes, megabytes, gigabytes, terabytes, duh!
   static double scale[] = { 1024.0, 1024.0*1024, 1024.0*1024*1024, 1024.0*1024*1024*1024, 0 };
      // kilo, mega, giga, tera, none
#ifdef CASEUP_SUFIX
   static char nextup[] =  { 'K', 'M', 'G', 'T', 0 };
#else
   static char nextup[] =  { 'k', 'm', 'g', 't', 0 };
#endif


I cannot say I like very much the compilation-time switch between cases (I don't understand this choice at all).

You may note also that top cannot handle more than tera unit, which is surely enough for all of us, and for long enough.
Your grand-children may need to add a few units ;-)


br.

--
2 + 2 = 5, for very large values of 2.

Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links