If executed ctrl+C,Please execute the following lines manually
execute: rm -rf /tmp/memory/block
execute: umount /tmp/memory
execute: rmdir /tmp/memory
Please wait 120 seconds
- 这个占用的是 shared共享内存,可以看到数量已经有变化了,并且free可用内存也相应减少了
- 等待120秒以后呢,该脚本运行结束,并且占用的内存也会被释放
[root@centos-76-qcow2-50g-3 ~]# sh free.sh 20480 120
total used free shared buff/cache available
Mem: 64264 451 63559 16 253 63300
Swap: 0 0 0
dd: writing to ‘/tmp/memory/block’: No space left on device
41943041+0 records in
41943040+0 records out
21474836480 bytes (21 GB) copied, 67.0879 s, 320 MB/s
total used free shared buff/cache available
Mem: 64264 451 43033 20496 20779 42797
Swap: 0 0 0
If executed ctrl+C,Please execute the following lines manually
execute: rm -rf /tmp/memory/block
execute: umount /tmp/memory
execute: rmdir /tmp/memory
Please wait 120 seconds
[root@centos-76-qcow2-50g-3 ~]#
[root@centos-76-qcow2-50g-3 ~]# free -m
total used free shared buff/cache available
Mem: 64264 451 63559 16 253 63300
Swap: 0 0 0
[root@centos-76-qcow2-50g-3 ~]#
rpm包下载安装
- 这个rpm包下载地址:内存占用rpm包.rar
下载好以后上传到linux主机上,然后通过下面方法安装好。
[root@ccx ~]# ls /opt
memload-7.0-1.r29766.x86_64.rpm
[root@ccx ~]# rpm -ivh /opt/memload-7.0-1.r29766.x86_64.rpm
Preparing… ################################# [100%]
Updating / installing…
1:memload-7.0-1.r29766 ################################# [100%]
[root@ccx ~]#
占用测试
- 基本环境弄好了,我们现在开始消耗内存看看【占用内存不要超过总内存】
我下面是在多个窗口中,注意看主机名 的变化
可以看到node2现在消耗了1G内存
[root@ccx ~]# free -