Profile Memory Allocation in Python (with support for Numpy arrays)

后端 未结 5 1215
自闭症患者
自闭症患者 2020-12-13 10:03

I have a program that contains a large number of objects, many of them Numpy arrays. My program is swapping miserably, and I\'m trying to reduce the memory usage, because it

5条回答
  •  既然无缘
    2020-12-13 11:08

    Have you tried valgrind with the massif tool?

    valgrind --tool=massif python yourscript.py
    

    it will create a file called massif.out.xxx which you can inspect via

    ms_print massif.out.xxx | less
    

    it has all kinds of useful information, but the plot right in the beginning should be what you're looking for. Also check out massif tutorial on the valgrind homepage.

    Using valgrind is quite advanced and there might be easier ways to do what you're looking for.

提交回复
热议问题