How To Calculate Correct SAP Memory Using free Command

Today we will discuss how to calculate correct SAP memory using free command .

There are multiple ways to check the memory requirement of the SAP systems .
Typically, we use ST02 transaction code to determine the memory in SAP.
However the values displayed in ST02 are somewhat different from values which are displayed via command ‘free’ in Linux operating systems.

Let us discuss this scenario and the cause:

What is ‘free’ command in Linux:

As the name defines itself, free command is used to know the amount of free memory in Linux.
‘free’ will display the amount of memory used (total,used,shared,cached) and swap memory in system along with buffer memory used by the kernel.

Typical output of free command will be as below:

$ free -m
            total     used     free  shared  buffers   cached
Mem:          8070    6243      1827      0      59     4811
-/+ buffers/cache:     2553    6697
Swap:        20480      293    20186
  • total: shows the total memory available in the system.
  • used: displays used memory by applications/programs.
  • free: denotes unused memory.
  • shared: will show the memory used by tmpfs
  • buffers: memory used by kernel buffers.
  • cached: denotes memory used by page cache and slab.
  • buffers/cache: displays sum of buffers and caches.
  • -m : displays output in megabytes

Here, total of 8070 MB is available for the SAP system.
Total used memory is =6243 MB and free memory is 1827 MB.

In addition to this, we can also consider cache memory which can be made available by Linux kernel.(4811 MB)

Hence the calculation of free memory = free (1827) +buffers(59)+cached (4811)= 6697MB.

However, cache memory consists of:

  • The page cache of the Linux kernel
  • Shared Memory areas of the database, such as the database cache
  • SAP Shared Memory areas, such as the SAP buffer and the extended memory.

Here only page cache can be made available and not the shared memory by database & SAP.
That is the reason, free command cannot be used to calculate exact memory.

Then how to determine the correct value?

Use /proc/meminfo command to specify the shared memory (shmem) currently used by system.

Therefore, final calculation of
Linux page cache=cached – shmem.

For e.g.

$ grep "^Cached|Shmem" /proc/meminfo
Cached:          5826472 kB
Shmem:           4917536 kB 

#Cached-Shmen = 9,08,936 kB (887MB)

This means currently 887 MB (cached-shmen) is now actual available page cache memory.
This Linux Page cache value is different from value defined by free command (in our case=4811MB) in the SAP environment.

Hope, you will now able to calculate correct SAP Memory Using free command.