Reputation: 16786
Is there a Python memory profiler that gives the memory usage for each method/function rather than line-by-line? Reason I am looking for a memory leak, but I am not sure where to look for it. The program is much to large for a line profiler.
--
when using cProfile, we get information how long each method runs. Is it possible to have similar profiling for the memory.
Upvotes: 0
Views: 173
Reputation: 26698
Try memprof
It logs the memory usage of all the variables during the execution of the decorated methods.
.
from memprof import *
@memprof
def my_func():
a = [1] * (10 ** 6)
b = [2] * (2 * 10 ** 7)
return a
if __name__ == '__main__':
my_func()
Upvotes: 1