Somehow the memory of my Python program takes up more and more memory when it starts (the VIRT and RES column) of the "top" command continues to grow.
However, I checked my code carefully twice, and I'm sure there are no memory leaks (I didn’t use a dictionary, not global variables. This is just the main method calling the sub method several times),
I used heapy to profile my memory usage with
from guppy import hpy; heap = hpy(); ..... print heap.heap();
every time the main method calls the sub method. Surprisingly, it always gives the same result. But memory usage just keeps growing.
I wonder if I used heapy right, or does VIRT and RES in the "top" command really not reflect the memory used by my code?
Or can anyone provide a better way to track memory usage in a Python script?
Thanks a lot!
source share