System memory statistics method after using memory file system

Source: Internet
Author: User

System memory statistics method after using memory file system

"Problem description"

In a Linux system, memory can be used as a disk for a portion of the space, called RAMDisk. This part of the memory space has high-speed reading and writing www.ahlinux.com

Features that can store data that is more demanding on disk IO and significantly improve service performance of the system.

RAMDisk is divided into two types, one is fixed space size space, and the hard disk partition exactly the same, you can format and mount the use of;

The TMPFS of the memory file system can be expanded and scaled up as needed. Both of these uses have been supported after kernel 2.4

Hold.

When using TMPFS, because it is not a single allocation, and the form of memory allocation is blurred, so how to calculate the overall memory usage of the system

Become a problem.

"Observation and Resolution"

When using the Ubuntu system, a simple test of the use of RAMDisk was made, and it was found that it was strange to use and not use RAMDisk.

Problem occurs. Specific as follows:

The memory partition does not have data when the situation is as follows,

[Email protected]:~# free-m

Total used free shared buffers Cached

mem:3851 2222 1629 0 63 847

-/+ buffers/cache:1310 2540

swap:1925 0 1925

[Email protected]:~# df-h

Filesystem Size used Avail use% mounted on

/dev/sda3 125G 4.9G 114G 5%/

Udev 1.9G 4.0K 1.9G 1%/dev

Tmpfs 771M 888K 770M 1%/run

None 5.0M 0 5.0M 0%/run/lock

None 1.9G 7.4M 1.9G 1%/RUN/SHM

The situation when writing 1G data to a memory partition is as follows,

[Email protected]:/run/shm# dd If=/dev/zero ibs=1m count=1024 of=./test.img

1024+0 Records in

2097152+0 Records out

1073741824 bytes (1.1 GB) copied, 2.22898 s, 482 MB/s

[Email protected]:/run/shm# df-h

Filesystem Size used Avail use% mounted on

/dev/sda3 125G 4.9G 114G 5%/

Udev 1.9G 4.0K 1.9G 1%/dev

Tmpfs 771M 888K 770M 1%/run

None 5.0M 0 5.0M 0%/run/lock

None 1.9G 1.1G 895M 54%/RUN/SHM

[Email protected]:/run/shm# free-m

Total used free shared buffers Cached

mem:3851 3245 605 0 64 1871

-/+ buffers/cache:1309 2541

swap:1925 0 1925

Before and after data comparison found that the main increase is the statistics of cached data, and the actual use of memory 1309 and almost unchanged. OK

It is thought that the data written to the memory partition actually increases the cached statistics. To further illustrate the situation, you can release the system

The cached data

[Email protected]:/run/shm# sync; echo "3" >/proc/sys/vm/drop_caches

[Email protected]:/run/shm# free-m

Total used free shared buffers Cached

mem:3851 2694 1156 0 0 1401

-/+ buffers/cache:1292 2558

swap:1925 0 1925

Because 1.1G of data is actually stored in the/RUN/SHM partition, cached is not fully used to describe the memory partition that is stored in the

The data is actually in the cached statistics.

After you finally release the memory partition's data and clean up the system cache, the following is the case

[Email protected]:/run/shm# rm-fr test.img

[Email protected]:/run/shm# free-m

Total used free shared buffers Cached

mem:3851 1676 2174 0 7 370

-/+ buffers/cache:1297 2553

swap:1925 0 1925

[Email protected]:/run/shm# df-h

Filesystem Size used Avail use% mounted on

/dev/sda3 125G 4.9G 114G 5%/

Udev 1.9G 4.0K 1.9G 1%/dev

Tmpfs 771M 888K 770M 1%/run

None 5.0M 0 5.0M 0%/run/lock

None 1.9G 7.4M 1.9G 1%/RUN/SHM

At this point, it can be found that in the system using memory partitioning, the actual memory data used should be free-m to obtain the use of memory conditions plus

The amount of data in the memory area, which is the amount of memory that the system really uses.

Summary

In a system that uses a memory file system to store data, it is necessary to fully consider the data usage of the memory file system when analyzing memory, and then accurately

Given the memory used in the system, the overall grasp of the system's resources, to prepare for further system analysis.

    • This article is from: Linux Tutorial Network

System memory statistics method after using memory file system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.