linux 清内存
2023-09-14 09:00:10 时间
注意:首先我们需要使用sync指令,将所有未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延迟的块 I/O 和读写映射文件。否则在释放缓存的过程中,可能会丢失未保存的文件。
的值可以为0~3之间的任意数字,代表着不同的含义: 0 – 不释放 1 – 释放页缓存 2 – 释放dentries和inodes 3 – 释放所有缓存
[root@ok Desktop]# cat /proc/sys/vm/drop_caches 0 [root@ok Desktop]# file /proc/sys/vm/drop_caches /proc/sys/vm/drop_caches: empty [root@ok Desktop]# echo 1 >/proc/sys/vm/drop_caches [root@ok Desktop]# free -h total used free shared buffers cached Mem: 11G 966M 10G 53M 392K 161M -/+ buffers/cache: 804M 10G Swap: 3.6G 0B 3.6G
查看内存条个数:
[root@ok Desktop]# dmidecode | grep -A16 "Memory Device$" Memory Device Array Handle: 0x0005 Error Information Handle: Not Provided Total Width: 64 bits Data Width: 64 bits Size: 8192 MB Form Factor: SODIMM Set: None Locator: ChannelA-DIMM0 Bank Locator: BANK 0 Type: DDR3 Type Detail: Synchronous Speed: 1600 MHz Manufacturer: Kingston Serial Number: 7633D911 Asset Tag: None Part Number: KHX1600C9S3L/8G -- Memory Device Array Handle: 0x0005 Error Information Handle: Not Provided Total Width: 64 bits Data Width: 64 bits Size: 4096 MB Form Factor: SODIMM Set: None Locator: ChannelB-DIMM0 Bank Locator: BANK 2 Type: DDR3 Type Detail: Synchronous Speed: 1600 MHz Manufacturer: Samsung Serial Number: 20A9C496 Asset Tag: None Part Number: M471B5173DB0-YK0
清除pagecache:
[root@ok ~]# sync [root@ok ~]# sysctl -w vm.drop_caches=1 vm.drop_caches = 1 [root@ok ~]# free -h total used free shared buffers cached Mem: 11G 1.1G 10G 82M 412K 192M -/+ buffers/cache: 980M 10G Swap: 3.6G 0B 3.6G
清空 dentries 和 inodes:
[root@ok ~]# sync [root@ok ~]# sysctl -w vm.drop_caches=2 vm.drop_caches = 2 [root@ok ~]# free -h total used free shared buffers cached Mem: 11G 1.2G 10G 79M 5.7M 224M -/+ buffers/cache: 959M 10G Swap: 3.6G 0B 3.6G
清空所有缓存 pagecache、dentries 和 inodes):
[root@ok ~]# sync [root@ok ~]# sysctl -w vm.drop_caches=3 vm.drop_caches = 3 [root@ok ~]# free -h total used free shared buffers cached Mem: 11G 1.1G 10G 101M 1.5M 210M -/+ buffers/cache: 956M 10G Swap: 3.6G 0B 3.6G
相关文章
- 查看linux系统是32位还是64位的方法
- 【Linux网络编程】无连接和面向连接协议的区别
- linux驱动开发--内核空间中内存的申请与释放
- Linux C 堆内存管理函数malloc()、calloc()、realloc()、free()详解
- 【Linux】linux常用查看命令
- Linux No volume control GStreamer plugins and/or devices found
- linux下查看最消耗CPU、内存的进程
- Linux内存管理机制中buffer和cache的区别
- Linux - 利用systemctl命令管理服务
- linux(ubuntu20.10):用apt方式安装php7.4.9
- 【Linux常见问题】SecureCRT 终端连接密钥交换失败错误
- Linux基础之查看linux发行版以及内核版本
- linux获取系统启动时间
- linux(centos8):禁用selinux(临时关闭/永久关闭)
- Linux文件类型与文件权限详解(二)
- Alpine Linux 中的 apk 命令讲解
- Linux 0.11-透过 fork 来看进程的内存规划-28
- Linux服务器安装Redis
- 【Linux 内核 内存管理】memblock 分配器编程接口 ④ ( memblock_alloc 函数 | memblock_alloc_base 函数 )
- 【Linux 内核 内存管理】memblock 分配器编程接口 ② ( memblock_add_range 函数分析 | memblock_insert_region 函数分析 )
- 【Linux 内核 内存管理】memblock 分配器 ⑤ ( Linux 内核中定义 memblock 分配器的位置 | ARM64体系架构下 Linux内核初始化 memblock 分配器流程 )
- 【Linux 内核 内存管理】memblock 分配器 ① ( memblock 分配器简介 | memblock 结构体成员分析 | 物理内存类型 与 内存类型 )
- 使用xshell链接本地虚拟机中的Linux
- sed——linux下对文本当控制操作(替换,追加)
- 【Linux】linux经常使用基本命令
- Linux 系统使用命令行工具查看 TLS/SSL 效期时间
- Linux 进程 cpu 使用排序 内存 使用排序
- L78.linux命令每日一练 -- 第11章 Linux系统管理命令 -- iostat和iotop
- L58.linux命令每日一练 -- 第九章 Linux进程管理命令 -- pgrep和kill
- Linux内核Thermal框架详解七、Thermal Core(6)
- Linux下CMake简明教程(二)同一目录下多个源文件
- Qt开发,跨平台,区分windows和linux
- Linux命令之ntpdate网络校时,时间
- Android/Linux之procrank查内存工具(九十九)
- 第六章 linux-设备树一
- Linux:echo命令详解
- 关于Linux内存管理的详细介绍,这篇万字长文值得你的收藏点赞
- Linux 搞懂物理内存和虚拟内存
- Linux基础入门到精通之与windows系统的不同