Find Memory Consumption Of Your Python Program.
import psutil
def get_memory_usage():
process = psutil.Process(os.getpid())
memory_info = process.memory_info()
print(f"Memory Usage: {memory_info.rss / (1024 ** 2):.2f} MB")
# Call this function in your code to print the memory usage
get_memory_usage()
Comments
Post a Comment