1

python | 分代回收

 1 year ago
source link: https://benpaodewoniu.github.io/2022/12/29/python186/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

python | 分代回收

2022-12-29python进阶内存管理

2

上一次标记清除遗留了两个问题。

  • 什么时候扫描
  • 扫描一次的代价可能很大

将可能存在循环引用的链表分成了 3 层「3 个链表」。

  • 0代
    • 0 代对象个数达到 700 个扫描一次
  • 1代
    • 0 代如果扫描 10 次,1 代扫描 1
  • 2代
    • 1 代如果扫描 10 次,2 代扫描 1

最开始放在 0 代,如果第一次扫描,发现不是垃圾,进行升级,升级到 1 代。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK