How to calculate the actual amount of RAM being used by the /tmp and /mfs directories

This article provides information on how to calculate actual amount of RAM being used by the /tmp and /mfs directories.

The /tmp and /mfs directories are RAM drives, which are known as memory disk (MD for short). As per PR81098/427302/697096/703437, there is a known memory leak bug in MFS (memory-based file system), which causes the physical pages to hold the contents of files that will not get deleted, when deleted.

For example, when the show system core-file core-file-info <> command is abnormally terminated, the temporary files created in /tmp will not be cleaned up. This results in the following issues:

  • Presence of stale files in /tmp (until system is rebooted).
  • Further allocation of memory to MFS on execution of the same command due to the presence of stale files (and memory not being re-usable).

Note: ‘show system core-files core-file-info <>’ will no longer cause this behavior. From Junos10.4R12 and 11.4R6, the working directory of such CLI will be changed from ‘/tmp’ (memory) to ‘/var/tmp’ (HD).

The output of show system storage does not show the actual used memory being mapped to /tmp and /mfs; whereas memory utilization is high, show chassis routing-engine is executed.

1. Obtain the unit IDs for the /tmp and /mfs directories; in this example, they are 8 and 9:

2. Check the page size being allocated by the root account under the shell; here it is 4096:

3. Write a live kernel coredump via the root account under the shell:

4. Check the active pages being mapped to the /tmp (unit 8) and /mfs (unit 9) directories by decoding the kernel coredump:

/mfs (unit 9) is 35850 pages * 4k = 146,841,600 bytes = 140 MB

/tmp (unit 8) is 265718 pages * 4096 = 1,088,380,928 bytes = 1 GB

About the author


Leave a Comment