Finding the free and used memory with the free command

  • by

Using the free command, the free and used memory in a Linux or Unix system can be found. The free command can be given from the command line as,

free

And the system responds with an output like,

             total    used     free  shared  buffers  cached
Mem:        960268  873136    87132       0    14652  168884
-/+ buffers/cache:  689600   270668
Swap:      2996116   95332  2900784

In the above output, the system has 960,268 kilobytes of total memory, which is less than the actual physical memory because the memory occupied by the kernel is not reported here. Of the total memory of 960,268 kilobytes, 873,136k is used and the rest is free. The shared memory column is obsolete and should be ignored. Next, we have 14,652k I/O buffers and a page cache usage of 168,884k (Total page cache is cached (168,884k) and Swap cached, which is not reported by free, but is available in the underlying /proc/meminfo). Since the buffers and cached are released as processes demand more memory in the system, the free memory is more than what is shown in the third column of the first line under free (87,132k, here). The free memory is free memory shown in the first line (87,132k) plus buffers (14,652k) plus cached (168,884k). The total of these three figures is 270,668k, which is the actual free memory and is shown under the column free in the next line of output. The rest of the memory (960,268k - 270,668k), 689,600k is the actual memory used and is reported under used in the -/+ buffers/cache line. The last line gives the amount of total swap memory on the disk, swap used and the free swap memory.

Command Line Options

The command line syntax is,

free [-b|-k|-m|-g] [-c count] [-l] [-o] [-t] [-s delay] [-V]

The command line options are,

free - Command Line Options
Option Description
-s delay print output continuously, delay seconds apart
-c count quit after count iterations. Requires -s option
-b report the memory in bytes
-k report the memory in kilobytes (default)
-m report the memory in megabytes
-g report the memory in gigabytes
-l display detailed low and high memory statistics
-o display in the old format, -/+ buffers/cache line is not displayed
-t display column totals
-V display the version information

Reference

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

You may like these, also

  • POSIX message queues in LinuxPOSIX message queues in Linux 1.0 POSIX Message queues POSIX interprocess comunication (IPC) was introduced in the POSIX.1b standard (IEEE Std 1003.1b-1993) for real time…
  • POSIX Shared Memory in LinuxPOSIX Shared Memory in Linux 1.0 Shared Memory Shared memory is the fastest method of interprocess communication (IPC) under Linux and other Unix-like systems. The…
  • POSIX Semaphores in LinuxPOSIX Semaphores in Linux 1.0 Semaphores Semaphores are used for process and thread synchronization. Semaphores are clubbed with message queues and shared memory under…
  • fork and exec system calls in Linuxfork and exec system calls in Linux 1.0 fork and exec system calls Suppose we wish to write a "shell program" which would execute another program. Now,…
  • Connecting two computers with Ethernet LAN cableConnecting two computers with Ethernet LAN cable Quite often, we wish to connect two computers back to back using an Ethernet LAN cable. It may be because…
  • D-Bus TutorialD-Bus Tutorial 1.0 D-Bus D-Bus is a mechanism for interprocess communication under Linux and other Unix-like systems. D-Bus has a layered architecture.…
  • Socket programming using the select system callSocket programming using the select system call 1.0 Client-Server Paradigm The Client-Server paradigm divides the software architecture of a system in two parts, the server and its…
  • System V message queues in LinuxSystem V message queues in Linux 1.0 Message queues Message queues are one of the interprocess communication mechanisms available under Linux. Message queues, shared memory and…
  • POSIX Threads Synchronization in CPOSIX Threads Synchronization in C 1.0 POSIX Threads Synchronization POSIX Threads provide multiple flows of execution within a process. The threads have their own stacks…
  • System V Shared Memory in LinuxSystem V Shared Memory in Linux 1.0 Shared Memory Shared memory is one of the three interprocess communication (IPC) mechanisms available under Linux and other Unix-like…