[Top][All Lists]

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

physmem: a new program to report memory information

From: Assaf Gordon
Subject: physmem: a new program to report memory information
Date: Thu, 30 Aug 2012 11:35:30 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4


Related to the previous sort+memory envvar usage thread: .

Attached is a suggestion for a tiny command-line program "physmem", that 
similarly to "nproc", exposes the gnulib functions "physmem_total()" and 

The code is closely modeled after nproc, and the "recommended" memory usage is 
calculated using sort's default_sort_size() .

The program works like this:
$ ./src/physmem --help
Usage: ./src/physmem [OPTION]...
Prints information about physical memory.

  -t, --total           print the total physical memory.
  -a, --available       print the available physical memory.
  -r, --recommended     print a safe recommended amount of useable memory.
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
      --si              like -h, but use powers of 1000 not 1024
      --help     display this help and exit
      --version  output version information and exit

Report physmem bugs to address@hidden
GNU coreutils home page: <>
General help using GNU software: <>
Report physmem translation bugs to <>
For complete documentation, run: info coreutils 'physmem invocation'

The actual working code (at the bottom of physmem.c) is:
    case total:
      memory = physmem_total();

    case available:
      memory = physmem_available();

    case recommended:
      memory = default_sort_size();

  fputs (human_readable (memory, buf, human_output_opts,1,1),stdout);
  fputs("\n", stdout);

So it's very simple, and rely on existing coreutils code.

Please let me know if this is something you'd be willing to include in 


Attachment: 0001-physmem-A-new-program-to-report-mem-information.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]