docs: def check_mem_usage(soft_percent=None, hard_percent=None):
      """
      Display a warning if we are running out of memory
      """
      soft_percent = soft_percent or config.memory.soft_mem_limit
      hard_percent = hard_percent or config.memory.hard_mem_limit
      used_mem_percent = psutil.virtual_memory().percent
      if used_mem_percent > hard_percent:
          raise MemoryError('Using more memory than allowed by configuration '
                            '(Used: %d%% / Allowed: %d%%)! Shutting down.' %
                            (used_mem_percent, hard_percent))
      elif used_mem_percent > soft_percent:
          msg = 'Using over %d%% of the memory in %s!'
          return msg % (used_mem_percent, socket.gethostname())