title: resource.getrusage always yields the same results
body: <p>I am trying to come up with my own memory measurement decorator. For my purposes, libs like memory profiler do not suit.
  Inspired by <a href="https://medium.com/survata-engineering-blog/monitoring-memory-usage-of-a-running-python-program-49f027e3d1ba" rel="nofollow noreferrer">this article</a>, I have drafted the following code.</p>
  <pre><code>import time
  from concurrent.futures import ThreadPoolExecutor
  import resource
  from time import sleep
  
  def test():
      a = [1] * (10 ** 7)
      time.sleep(3)
  
  
  class MemoryMonitor:
  
      def __init__(self):
          self.keep_measuring = True
  
      def measure_usage(self):
          max_usage = 0
          while self.keep_measuring:
  
              max_usage = max(
                  max_usage,
                  resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
              )
              sleep(0.1)
          return max_usage
  
  
  if __name__ == '__main__':
      func = test
      with ThreadPoolExecutor() as executor:
          monitor = MemoryMonitor()
          mem_thread = executor.submit(monitor.measure_usage)
          try:
              fn_thread = executor.submit(func)
              result = fn_thread.result()
          finally:
              monitor.keep_measuring = False
              max_usage = mem_thread.result()
          print(&quot;Peak memory usage for {}: {}&quot;.format(func.__name__, max_usage))
  </code></pre>
  <p>The strange thing for me is that for some reason, it always yields the same max usage result, no matter if I put <code>a = [1] * (10 ** 7)</code> or <code>a = [1] * (10 ** 6)</code>, or <code>a = [1] * (10 ** 5)</code>. Is there somethiing I am missing ?</p>