Skip to content Skip to sidebar Skip to footer

How To Keep Track Of Virtual Memory Used When Running Python Code?

I have a Python package I am benchmarking for virtual memory used. At the moment, this isn't very precise. I submit the script e.g. python script1.py and look at the time and re

Solution 1:

Yes, there is - It's called memory_profiler. Once you've gone through and added the @profile decorator to the functions you would like to profile, you can use;

python -m memory_profiler example.py

Solution 2:

There's also memory_infopsutil. https://pythonhosted.org/psutil/

Place at the beginning of the script:

importpsutilp= psutil.Process()

and given that the code is running correctly, place this on the last line:

print(p.memory_info())

Post a Comment for "How To Keep Track Of Virtual Memory Used When Running Python Code?"