Linux what kind of memory




















Another item that is quite important is the Page Cache. Once from the metadata the actual block address of the file is known, it is picked up by the kernel for processing. Read more: What is difference between page cache and buffer? Read More: Understanding the Linux Kernel. Kernel read and write operations operate on main memory. Whenever any read or write operation is performed, the kernel first needs to copy the required data into memory:.

Read More: What is cache in "free -m" output and why is memory utilization high for cache? In other words we can also frame this question as, why we should not clear the buffers and page cache so frequently?

To demonstrate this in Linux memory management, we will take a very simple example: I will create a small file with some random text:. Next we will clear the buffers and cache. Now since the caches are clear, we see that it takes around 0. Now since we have read the file once, it will also be available in our page cache so if we try to read the same file again, it should be picked from the page cache.

As you see now the read time is hardly 0. As we know, the kernel keeps filling the page cache with pages containing data of block devices. Could somebody please explain the difference? Ok, let me try to paraphrase and tell me if I am wrong. VIRT: This memory used contains libs that will be shared to other programs. The other programs in return will not use more memory because they are sharing this memory RES: This is your total memory in use excluding swapped.

SHR: I have no idea. It sounds the same as VIRT. To elaborate further Each process that is running perceives that it has a very large chunk of completely-empty memory which is available entirely to itself. Several gigbytes, perhaps. In all of that space, there is no one else but "me. And yet, each process has the same perception, with regards to itself!

How can this be? The answer is: it's an illusion , called "virtual memory. Only the operating system knows the truth: that the virtual-memory space for each process is divided into equal-sized pages, and the content of only To the process, all of this virtual memory is created equal. The process cannot perceive which pages are so-called resident right now, nor can it perceive where in physical memory each resident page might actually be.

Nor does it have to: it simply references "its" memory, resident or not, and the operating system dutifully tracks its progress. This process is the first to be started and will get process ID 1.

Its duty is to start other services and programs during the lifetime of the system. Each program will consume some amount of memory, depending on the program size and the related data. The first command to obtain available memory information is the perfectly named tool free. This utility shows two different types of memory: normal memory and swap memory. Swap is a type of memory that you want to avoid needing as much as possible. If it would be used, then it means your normal memory is full.

The system will then leverage the swap memory to temporarily store data, at the cost of disk operations. As they are much slower than normal RAM, your system will be impacted. In this screenshot, we see the swap is not used, which is good. This file is very extensive, so have a look at it on your system:.

A partial output listing showing how memory is used. Memory management under Linux is extensive and changed over time to what it is now. This results in a delicate system that optimizes memory usage as much as possible.

The system does a lot of repetition, including reading the same files or data. Everything that goes into memory and is no longer needed, will be kept for a little bit longer. If you then request the same data while it is in memory, you will get it almost instantly.

This is what happens when you run a find command on a particular directory the first time, which usually takes a while. Run it again and it will be much quicker.

A page cache optimizes access to files. Active is the total of Active anon and Active file. These provide insights in the configured swap memory and how much is left. Ideally, the SwapFree value is equal to SwapTotal, meaning no swap is in use at that time. Swapping is disk intensive. The Dirty field refers to data that is stored in memory and still needs to be written to the disk. Note: if you repeat this command, you will see the effect of smart memory management. In that case, the value before and after will most likely be the same, as some data was cached and directly returned as a finished action.

The kernel does a lot of repetition during the time it is running. Some objects, like asking for the specific inode of a file may be performed thousand times a day. The vmstat command is a useful tool that reports virtual memory statistics. The detailed description listed below provides an explanation for each value in case you need assistance in analyzing the results. The top command is useful to check memory and CPU usage per process.

It displays information about:. Aside from providing you with essential memory information, the top command provides a limited interactive interface. It is possible to manipulate and configure operations by using command-line options. The man command in Linux man top provides a comprehensive list of all available variations. The information the htop command provides is similar to the top command. However, the real advantage to the htop command is its user-friendly environment and improved controls.

The command uses color for its output, provides full command lines for processes, as well as the option to scroll both vertically and horizontally. Using a graphical interface for server administration is not common practice.



0コメント

  • 1000 / 1000