In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to manually release memory in Linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
How do we describe a file in the process? We use catalog items (dentry) and index nodes (inode). They are defined as follows:
The so-called "file" is the information stored on the media in a certain form, so a file actually contains two aspects of information, one is the stored data itself, and the other is information about the organization and management of the file. In memory, each file has a dentry (directory entry) and inode (index node) structure.
Dentry records the file name, parent directory and other information, which forms the tree structure we see, while the information about the organization and management of the file is mainly stored in inode, which records the location and distribution of the file on the storage medium. At the same time dentry- > d_inode points to the corresponding inode structure. Dentry and inode have a many-to-one relationship, because it is possible that a file has several file names (hard link, hard link)
Inode represents the physical sense of the file, through inode you can get an array, this array records the location of the file contents, such as the file is located in the hard disk block 3, 8, 10, then the content of this array is 3pjing8 10. The index node number inode- > i_ino is unique in the same file system, and the kernel can calculate the location of its corresponding inode on the media as long as it is based on i_ino. As far as the hard disk is concerned, according to the i_ino, we can calculate which block (block) the corresponding inode belongs to, so as to find the corresponding inode structure. But inode alone cannot describe all file systems, and for a particular file system, such as ext3, it is described in memory with ext3_inode_info. It is a "container" that contains inode.
Several modes of drop_caches:
To free pagecache:
* echo 1 > / proc/sys/vm/drop_caches
To free dentries and inodes:
* echo 2 > / proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
* echo 3 > / proc/sys/vm/drop_caches
As this is a non-destructive operation, and dirty objects are notfreeable, the user should run "sync" first in order to make sure allcached objects are freed.
This tunable was added in 2.6.16.
Note: the use of modes 2 and 3 in production is prohibited.
Manually clean up the cache (prevent the use of swap):
[root@testserver] # free-m
[root@testserver ~] # sync # forces the changed content to be written to disk immediately and the hyperblock information is updated
[root@testserver ~] # cat / proc/sys/vm/drop_caches
0
[root@testserver ~] # echo 1 > / proc/sys/vm/drop_caches
[root@testserver] # free-m
Supplement: large pages of memory can avoid using swap
This is the end of the content of "how to manually free memory in Linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.