def get_process_with_highest_memory():
    """Find the process with the highest memory consumption."""
    processes = []
    for proc in psutil.process_iter(["pid", "name", "memory_info"]):
        try:
            processes.append((proc.info["pid"], proc.info["name"], proc.info["memory_info"].rss))
        except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
            pass

    # Sort by memory usage (descending)
    processes.sort(key=lambda x: x[2], reverse=True)

    if processes:
        return processes[0]
    return None
Find the process with the highest memory consumption.
docs/usage/memory_sentinel.py