我有一个非常简单的脚本,它分配内存,dels唯一引用一个相当大的对象,一直打印heapy和pidstat报告.在运行脚本之后,heapy告诉我,当pidstat告诉我相反时,不应该使用太多内存:
from guppy import hpy
import time
import sys
import os
'''
1) print heapy and pidstat report after starting and before actually doing any work
2) allocate some memory in a simple 2d array
3) print heapy and pidstat report
4) del the d2 array (attempt at garbage collection)
5) print heapy and pidstat report
6) sleep so pidstat can continue to be run to check on memory
'''
def pidstat(msg):
print '===============================' …Run Code Online (Sandbox Code Playgroud)