Linux: How to put a load on system memory?

后端 未结 12 2122
清酒与你
清酒与你 2021-02-10 07:54

I\'m working on a small function, that gives my users a picture of how occupied the CPU is.

I\'m using cat /proc/loadavg, which returns the well known 3 num

12条回答
  •  时光取名叫无心
    2021-02-10 08:25

    The simplest way I have found to load the RAM (and SWAP) is by using Perl:

    my $allocation = "A" x (1024 * 1024 * $ARGV[0]);
    print "\nAllocated " . length($allocation) . "\n";
    

提交回复
热议问题