Why to use the tmpfs , ramfs for Oracle AMM(Automatic Memory Management) ?

Shared Memory
Shared Memory is an efficient means of passing data between programs. Shared memory allows one or more processes to communicate via memory that appears in all of their virtual address spaces. POSIX , System-V provides a standardized API for using shared memory.
The POSIX shared memory calls seem to be based on the UNIX philosophy that if you do Input/Output operations on an object, that object has to be a file. So, since we do read and write to a POSIX shared memory object, the latter is to be treated as a file. A POSIX shared memory object is a memory-mapped file. POSIX shared memory files are provided from a tmpfs file system mounted at /dev/shm. The individual shared memory files are created using the shm_open system call under /dev/shm. There are just two specialized POSIX shared memory system calls, shm_open and shm_unlink, which are analogous to open and unlink system calls for files.
The size of a System V shared memory segment is fixed at the time of creation. By contrast, for a mapping backed by a file or by a POSIX shared memory object, we can use ftruncate() to adjust the size of the underlying object, and then re-create the mapping using munmap() and mmap().
Why to use the POSIX Shared Memory in AMM ?
To manage both the SGA and PGA using the single parameter memory_target where we need to reduce the size of SGA incase of requirement for PGA and vice versa, SysV SHM interface is not that flexible that it could downsize and release memory from a single shared memory segment. So Oracle is using Linux’es POSIX-oriented SHM implementation as explained above. So to implement the POSIX Shared memory we need ramfs or tmpfs.
After starting the Oracle instance you can see the list of files created under the /dev/shm file system in the below image.
Calculate the memory allocated for a database at OS level ?

SQL> show parameter memory_target;

NAME                                 TYPE        VALUE
———————————— ———– —————
memory_target                        big integer 900M
I have allocated 900M(memory is less than 1024M so the memory granule size is 4MB as you can see in the above image otherwise it will be 16MB).
now we will check the number of granules mapped to the processes.
[oracle@OraLinux7orcl ~]$ pmap `pgrep -f lgwr` | grep 4096K | wc -l

Total 225 granules allocated. So 225*4MB=900M.

The output of pmap is like below

[oracle@OraLinux7orcl ~]$ pmap `pgrep -f lgwr` | grep CMSCHEMA | grep -v dat
24466:   ora_lgwr_CMSCHEMA
0000000060000000      4K r–s- ora_CMSCHEMA_1601863681_0
0000000060001000   4092K rw-s- ora_CMSCHEMA_1601863681_0
By this we can calculate the size according to the database or SID.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s