gpt4 book ai didi

python - python内存中的对象

转载 作者:太空宇宙 更新时间:2023-11-03 18:28:24 25 4
gpt4 key购买 nike

了解内存中对象的命令是什么?

我的问题如下:

1) 在执行函数之前,我有 1.71 Go 的完整内存

2)执行读取csv文件的函数后,内存为1.98 Go

3)删除函数创建的变量后,我的内存是1.92 Go。

==>我损失了0.21,不知道为什么!!!

def import():
df1 = pd.read_excel('filename.xlsx')
return df1

aa = import()
del aa

最佳答案

import gc
gc.get_objects() # returns a list of objects tracked by CPython's garbage collector

我建议您阅读以下内容:http://utcc.utoronto.ca/~cks/space/blog/python/GetAllObjects及其后续http://utcc.utoronto.ca/~cks/space/blog/python/GetAllObjectsII .

关于python - python内存中的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22786132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com