简体   繁体   中英

shell/Python script to utilize memory 100% for 20 mins

Is there any python/Shell script to make memory 100% usage for 20 minutes.

Memory size is very big 4TB.

Operating System Linux. Python version 2.7

How about

import time
l = []
t = time.time()
while True:
  try:
    l.append('string')  # pack your memory
  except MemoryError:
    break
while (time.time()-t) < 20*60:  # repeat for 20 minutes.
  l[0] = 'string'

Is there any python/Shell script to make memory 100% usage for 20 minutes.

To be technical, we need to be precise. 100% usage of the whole memory by a single process isn't technically possible. Your memory is shared with other processes. The fact that the kernel is in-memory software debunks the whole idea.

Plus, a process might start another process, say you run Python from the shell, now you have two processes (the shell and Python) each having their own memory areas.

If you mean by that a process that can consume most of ram space, then yes that's not impossible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM