I have a Python script and I would like to measure the amount of memory that it uses. I have tried memory_profiler but I could not find the right option for me.
I would like something that I can use as:
results = {}
for i in range(10):
l = [1]*i*1000
memory = compute_used_memory()
results[i] = memory
in order to know the amount of memory used during different phases of the program.
EDIT: I do not have much experience but I'll try to explain the problem better. I need to deploy my code on a machine where I will have access only to a limited amount of memory (such as 1 GB). As a consequence I need to know how much memory my code will use. As the code will run incrementally with increasing complexity I need to make sure that the amount of memory used converges to a maximum value. For this reason I need to measure how the amount of memory used changes at different stage of the execution that is in this case represented by a for loop .