System memory statistics after memory file system is used

Source: Internet
Author: User
After the memory file system is used, the system memory statistical method [problem description] in Linux, memory can be divided into a part of space for use as a disk, called Ramdisk. This part of the memory space has the high-speed read/write www.2cto.com feature, you can store those data that requires high disk I/O... after the memory file system is used, the system memory statistical method [problem description] in Linux, memory can be divided into a part of space for use as a disk, called Ramdisk. This part of memory space has the feature of high-speed reading and writing www.2cto.com, which can store data with high requirements for disk I/O, significantly improving the service performance of the system. Ramdisk can be divided into two types: one is a fixed space, which is exactly the same as a hard disk partition and can be formatted and mounted for use; the other is in the form of a memory file system tmpfs, it can be expanded or reduced as needed. These two methods are supported after kernel 2.4. When tmpfs is used, the calculation of the overall memory usage of the system becomes a problem because it is not a single allocation and the memory allocation form is vague. [Observation and solution] during the use of ubuntu, a simple test on the form of Ramdisk was conducted, and it was found that there were strange problems when Ramdisk was used or not used. The details are as follows: root @ peter :~ # Free-m total used free shared buffers cached Mem: 3851 2222 1629 0 63 847-/+ buffers/cache: 1310 2540 1925 Swap: 1925 0 root @ peter :~ # Df-h Filesystem Size Used Avail Use % Mounted on/dev/sda3 125G 4.9G 114G 5%/udev 1.9G 4.0 K 1.9G 1%/dev tmpfs 771 M 888 K 770 M 1%/run none 5.0 M 0 5.0 M 0%/run/lock none 1.9G 7.4 M 1.9G 1%/run/shm write 1G data to the memory partition as follows, root @ peter:/run/shm # dd if =/dev/zero ibs = 1 M 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 root @ peter:/run/shm # Df-h Filesystem Size Used Avail Use % Mounted on/dev/sda3 125G 4.9G 114G 5%/udev 1.9G 4.0 K 1.9G 1%/dev tmpfs 771 M 888 K 770 M 1%/run none 5.0 M 0 5.0 M 0%/run/lock none 1.9G 1.1G 895 M 54%/run/shm root @ peter: /run/shm # free-m total used free shared buffers cached Mem: 3851 3245 605 0 64 1871-/+ buffers/cache: 1309 2541 Swap: the data comparison before and after 1925 0 1925 found that the main increase was the cached data statistics, while the actual memory usage of 1309 was almost unchanged. We can probably think that the data written to the memory partition actually increases the cached statistics. To further illustrate this situation, you can release the system's cached data root @ peter:/run/shm # sync; echo "3">/proc/sys/vm/drop_caches root @ peter:/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 the/run/shm partition actually stores 1g of data, cached is not fully used. it indicates that the data stored in the memory partition is actually in the statistics of cached. After the data in the memory partition is released and the system cache is cleared, root @ peter:/run/shm # rm-fr test. img root @ peter:/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 root @ peter: /run/shm # df-h Filesystem Size Used Avail Use % Mounted on/dev/sda3 125G 4.9G 114G 5%/udev 1.9G 4.0 K 1.9G 1%/dev tmpfs 771 M 888 K 770 M 1%/run none 5.0 M 0 5.0 M 0%/run/lock none 1.9G 7.4 M 1.9G 1%/run/shm now, we can find that the memory data actually used in the system using the memory partition, it should be free-m to get the memory usage plus the data volume in the memory area, which is the actual amount of memory used by the system. [Conclusion] in the system that uses the memory file system to store data, the data usage of the memory file system should be fully taken into account when analyzing the memory, so as to accurately display the memory usage of the system, overall grasp of system resources and prepare for further system analysis.

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.