python-3.x - Python tracemalloc,什么是大小和计数?
问题描述
我正在使用 tracemalloc 库来查明我的应用程序中的内存问题。
这是我正在使用的代码。
tracemalloc.start()
snapshot = tracemalloc.take_snapshot()
top_stats = snapshot.statistics('lineno')
numStats = len(top_stats)
statsThreshold = 100
if numStats < statsThreshold:
numStatsCollections = numStats
else:
numStatsCollections = statsThreshold
collectedStats = str(top_stats[:numStatsCollections])
self.memLogger.error('\n----------START----------\n' +
collectedStats.replace(',','\n') + '\n----------END----------\n')
示例输出如下。
[<Statistic traceback=<Traceback (<Frame filename='C:\\Users\\TheUser\\AppData\\Local\\Programs\\Python\\Python38\\lib\\base64.py' lineno=87>
)> size=10308228 count=107>
<Statistic traceback=<Traceback (<Frame filename='C:\\Users\\TheUser\\AppData\\Local\\Programs\\Python\\Python38\\lib\\json\\decoder.py' lineno=353>
)> size=3549589 count=37774>
有人可以解释这些值的含义吗?
- 线诺
- 尺寸
- 数数
解决方案
推荐阅读
- javascript - 这个函数的空间复杂度是多少?
- caching - 由于分布式缓存需要网络调用,在某些情况下直接从数据库读取不是有益的吗?
- python - 使用预训练的 BERT 模型进行错误多类文本分类
- javascript - 用 jest/enzyme 模拟模块功能
- tar - Tar --files-from 在结果中加倍文件
- ruby-on-rails - TypeError:无法读取未定义的属性“类型”
- php - 如何在购物车中添加选择的产品尺寸和颜色?
- java - 创建一个日期时间对象来表示一个实例,而不考虑用于字符串操作的时区
- php - 查询以在每个月的每一天旁边显示结果
- swift - TableView返回视图时隐藏在搜索栏下的第一个单元格