C语言实现消耗Linux内存,目的提高Linux环境的内存使用率,使得性能数据发生明显变化。
使用方法:
编译#
gcc test_eatMem.c -o test_eatMem
运行# ./test_eatMem
释放消耗的内存:
1)查询进程操作#
jobs
+ Stopped ./test_eatMem
2)关闭进程操作#
kill -9 %
1
3)观察Memory数据#
free -g
4)释放内存# for i in `seq 1 100`; do echo 3 > /proc/sys/vm/drop_caches & done &