Linux uses instructions to release cache methods
The caching mechanism of the Linux system is quite advanced. It targets dentry (for VFS, accelerating the conversion of file path names to inodes), Buffer Cache (for reading and writing disk blocks) and Page Cache (for reading and writing file inodes). ) to perform caching operations. However, after a large number of file operations are performed, the cache will basically use up the memory resources. But in fact, our file operation has been completed, and this part of the cache is no longer used. At this time, can we just watch the cache occupy the memory space?
So, we still need to manually release the memory under Linux, which is actually the operation of releasing the cache.
To achieve the purpose of releasing the cache, we first need to understand the key configuration file /proc/sys/vm/drop_caches. This file records the parameters of cache release. The default value is 0, which means the cache is not released. Its value can be any number between 0 and 3, representing different meanings:
0 – Not released
1 – Release page cache
2 – Release dentries and inodes
3 – Free all caches
After knowing the parameters, we can use the following instructions to operate according to our needs.
First we need to use the sync command to write all unwritten system buffers to disk, including modified i-nodes, delayed block I/O and read-write mapping files. Otherwise, unsaved files may be lost during the cache release process.
#sync
Next, we need to write the required parameters into the /proc/sys/vm/drop_caches file. For example, if we need to release all caches, enter the following command:
#echo 3 > /proc/sys/vm/drop_caches
This command will take effect immediately after being entered, and you can check that the available memory has obviously increased.
To query the parameters released by the current cache, you can enter the following command:
#cat /proc/sys/vm/drop_caches
The above is an introduction to how Linux uses commands to release the cache. If you feel that your computer is getting more and more stuck, it may be that your memory is occupied a lot. You might as well clean up the computer garbage.
The above is the detailed content of Linux uses instructions to release cache methods. For more information, please follow other related articles on the PHP Chinese website!

Linuxisidealforcustomization,development,andservermanagement,whileWindowsexcelsineaseofuse,softwarecompatibility,andgaming.Linuxoffershighconfigurabilityfordevelopersandserversetups,whereasWindowsprovidesauser-friendlyinterfaceandbroadsoftwaresupport

The main difference between Linux and Windows in user account management is the permission model and management tools. Linux uses Unix-based permissions models and command-line tools (such as useradd, usermod, userdel), while Windows uses its own security model and graphical user interface (GUI) management tools.

Linux'scommandlinecanbemoresecurethanWindowsifmanagedcorrectly,butrequiresmoreuserknowledge.1)Linux'sopen-sourcenatureallowsforquicksecurityupdates.2)Misconfigurationcanleadtovulnerabilities.Windows'commandlineismorecontrolledbutlesscustomizable,with

This guide explains how to automatically mount a USB drive on boot in Linux, saving you time and effort. Step 1: Identify Your USB Drive Use the lsblk command to list all block devices. Your USB drive will likely be labeled /dev/sdb1, /dev/sdc1, etc

Cross-platform applications have revolutionized software development, enabling seamless functionality across operating systems like Linux, Windows, and macOS. This eliminates the need to switch apps based on your device, offering consistent experien

Artificial Intelligence (AI) is rapidly transforming numerous sectors, from healthcare and finance to creative fields like art and music. Linux, with its open-source nature, adaptability, and performance capabilities, has emerged as a premier platfo

Looking for a fast, minimal, and efficient Linux distribution without a graphical user interface (GUI)? Lightweight, GUI-less Linux distros are perfect for older hardware or specialized tasks like servers and embedded systems. They consume fewer res

Wine 10.0 stable version release: Running Windows applications on Linux to a higher level Wine, this open source and free application, allows Linux users to run Windows software and games on Unix/Linux operating systems, ushering in the release of the 10.0 stable version! This version has been provided with source code and binary package downloads, and supports various distributions such as Linux, Windows and Mac. This edition embodies a year of hard work and over 8,600 improvements, bringing many exciting improvements. Key highlights include: Enhanced support for Bluetooth devices. Improve support for HID input devices. Optimized performance of 32-bit and 64-bit applications.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor
