Created
November 1, 2023 22:21
-
-
Save ThomasParistech/3befa6f691806eb672af046a3a416197 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psutil | |
def get_total_ram_available_bytes() -> int: | |
"""Return the total number of bytes available on the platform.""" | |
return int(psutil.virtual_memory().total) | |
def get_total_ram_used_bytes() -> int: | |
"""Return the number of bytes currently used on the platform.""" | |
return int(psutil.virtual_memory().used) | |
def get_pid_ram_used_bytes(pid: int) -> int: | |
"""Return the number of bytes currently used by a given process. | |
(Use os.getpid() to get current process ID)""" | |
return int(psutil.Process(pid).memory_info().rss) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment