class_docstr: Helper class for raising errors on low memory.
  
  This presents a much cleaner error message to users than what would happen
  if we actually ran out of memory.
  
  The monitor tries to use the cgroup memory limit and usage if it is set
  and available so that it is more reasonable inside containers. Otherwise,
  it uses `psutil` to check the memory usage.
  
  The environment variable `RAY_MEMORY_MONITOR_ERROR_THRESHOLD` can be used
  to overwrite the default error_threshold setting.
  
  Used by test only. For production code use memory_monitor.cc
class_docstr_tok: ["Helper","class","for","raising","errors","on","low","memory",".","This","presents","a","much","cleaner","error","message","to","users","than","what","would","happen","if","we","actually","ran","out","of","memory",".","The","monitor","tries","to","use","the","cgroup","memory","limit","and","usage","if","it","is","set","and","available","so","that","it","is","more","reasonable","inside","containers",".","Otherwise",",","it","uses","`","psutil","`","to","check","the","memory","usage",".","The","environment","variable","`","RAY_MEMORY_MONITOR_ERROR_THRESHOLD","`","can","be","used","to","overwrite","the","default","error_threshold","setting",".","Used","by","test","only",".","For","production","code","use","memory_monitor.cc"]
code: def raise_if_low_memory(self):
      if self.disabled:
          return
  
      if time.time() - self.last_checked > self.check_interval:
          self.last_checked = time.time()
          used_gb, total_gb = self.get_memory_usage()
  
          if used_gb > total_gb * self.error_threshold:
              raise RayOutOfMemoryError(
                  RayOutOfMemoryError.get_message(
                      used_gb, total_gb, self.error_threshold
                  )
              )
          else:
              logger.debug(f"Memory usage is {used_gb} / {total_gb}")
  
file_path: ray/python/ray/_private/memory_monitor.py
imports: import logging
  import os
  import platform
  import sys
  import time
  import ray
  import psutil
label_desc: Use image node_id 3 for calling the MemoryMonitor obj's underlying member method code with example usage: obj.raise_if_low_memory() without return types