Linux: How to put a load on system memory?

后端 未结 12 1982
清酒与你
清酒与你 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:24

    Very simple actually: install stress tool and do:

    stress --vm X --vm-bytes YM
    
    • replace X with the number of worker you want to spawn and "malloc()" your RAM
    • replace Y with the amount of memory that each worker has to allocate

    Example:

    stress --vm 2 --vm-bytes 128M
    

提交回复
热议问题