Skip to content

[FEATURE] free -h switch request. #17274

Open

Description

@cederom

Is your feature request related to a problem? Please describe.

  • free is built in utility that shows memory usage.

  • On platforms with large amounts of memory result of free is hard to read, for instance on rPI4B:

    nsh> free
          total       used       free    maxused    maxfree  nused  nfree name
    18446744073637310464      2279218446744073637287672      2346418446744073637287672     28      1 Umem
    

Describe the solution you'd like

Common approach in Unix / POSIX [1] utilities is to use -h switch to produce "human readable" output, for instance df [2]:

-h
The human-readable option selects to format sizes in metric units (e.g. 10 MB). Available in the BSD and GNU coreutils.

[1] https://en.wikipedia.org/wiki/List_of_POSIX_commands
[2] https://en.wikipedia.org/wiki/Df_(Unix)

Describe alternatives you've considered

No response

Verification

  • I have verified before submitting the report.

Activity

  1. added
    Type: Enhancement
    on Nov 4, 2025
  2. self-assigned this
    on Mar 2, 2026
  3. linguini1 commented on Mar 2, 2026

    @linguini1
    Contributor

    This one will be interesting since free is implemented as just performing cat /proc/meminfo essentially.

    I noticed the output of cat /proc/meminfo on my Linux machine is completely different from NuttX. Memory "chunks" are listed one per newline and the output is shown in units of kB. The free outputs between Linux and NuttX are very similar though.

    According to man free:

           free  displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel. The in‐
           formation is gathered by parsing /proc/meminfo. The displayed columns are:
    
           total  Total usable memory (MemTotal and SwapTotal in /proc/meminfo). This includes the physical and swap memory minus a few reserved bits and  kernel
                  binary code.
    
           used   Used or unavailable memory (calculated as total - available)
    
           free   Unused memory (MemFree and SwapFree in /proc/meminfo)
    
           shared Memory used (mostly) by tmpfs (Shmem in /proc/meminfo)
    
           buffers
                  Memory used by kernel buffers (Buffers in /proc/meminfo)
    
           cache  Memory used by the page cache and slabs (Cached and SReclaimable in /proc/meminfo)
    
           buff/cache
                  Sum of buffers and cache
    
           available
                  Estimation  of  how  much  memory  is  available for starting new applications, without swapping. Unlike the data provided by the cache or free
                  fields, this field takes into account page cache and also that not all reclaimable memory slabs will be reclaimed due to  items  being  in  use
                  (MemAvailable in /proc/meminfo, available on kernels 3.14, emulated on kernels 2.6.27+, otherwise the same as free)
    

    So I think solving this issue will involve:

    • Changing the output of proc/meminfo to match a more standard representation (and which will be easier to parse)
    • Changing the free command to parse /proc/meminfo directly and then print the tabular version according the man-pages with the desired command-line options.
  4. added this to the future milestone on Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type: Enhancement

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions