内存消耗测试

来源:互联网 发布:tcp端口号怎么看 编辑:程序博客网 时间:2024/06/02 16:58

今天在阅读邮件时发现某位大神给出了两个可以快速消耗内存的方法。

Here's 2 commands you can run on a test system that will consume a significant amount of memory without installing any additional software.host:~ # dd if=/dev/zero of=/dev/null bs=1Twhere bs (block size) is around the size of your memory commit limit (cat /proc/meminfo and note CommitLimit). Of course you can use any value you like depending on how much memory you want to use. If you specify too large of a value it will fail to allocate the buffer.Also you can just tell bash to consume as much memory as possible with a command line like this:host:~ # A=0; while true; do A="$A$A"; done-bash: xrealloc: cannot reallocate 18446744071562068096 bytes (0 bytes allocated)It will keep running until it consumes so much memory it fails to allocate anymore for its internal buffer.

仅供参考

0 0
原创粉丝点击