如何解决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>
谁能解释一下这些值是什么意思?
- lineno
- 尺寸
- 计数
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。