code: def _get_memory_base(gallery_conf):
      
      if not gallery_conf['show_memory']:
          memory_base = 0
      else:
          # There might be a cleaner way to do this at some point
          from memory_profiler import memory_usage
          sleep, timeout = (1, 2) if sys.platform == 'win32' else (0.5, 1)
          proc = subprocess.Popen(
              [sys.executable, '-c',
               'import time, sys; time.sleep(%s); sys.exit(0)' % sleep],
              close_fds=True)
          memories = memory_usage(proc, interval=1e-3, timeout=timeout)
          kwargs = dict(timeout=timeout) if sys.version_info >= (3, 5) else {}
          proc.communicate(**kwargs)
          # On OSX sometimes the last entry can be None
          memories = [mem for mem in memories if mem is not None] + [0.]
          memory_base = max(memories)
      return memory_base
docs: Get the base amount of memory used by running a Python process.