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

Popular posts from this blog

Express Production Setup - 4 | HELMET

Express Production Setup - 3 | CORS

Ensuring File Creation in the Current Directory when Converting Python (.py) Script to Executable (.exe).