python ref counting based garbage collection
不用中文都不讓釋出
class Foo:
def __init__(self):
self.other = None
def ref(self, other):
self.other = other
def __del__(self):
print('Foo instance deletion')
# case 1
f = Foo()
del f # you should see deletion msg here
# case 2
f = Foo()
g = Foo()
f.ref(g)
del g
del f # you should see two deletion msgs here
# case 3
f = Foo()
g = Foo()
f.ref(g)
g.ref(f) # create circle refs
del f
del g
# you wont see any deletion msg above
import gc
gc.collect()
# now you will see it
def foo():
try:
print('in')
yield
finally:
print('out')
# case 1
f = foo()
del f
# case 2
f = foo()
next(f)
del f
相關文章
- [Javascript] garbage collectionJavaScript
- C語言垃圾回收(Garbage Collection)C語言
- JVM垃圾回收機制(Garbage Collection)JVM
- [Memory leak] 3. Garbage collection in Closure
- 深入理解Java中的Garbage CollectionJava
- Java的垃圾回收(Garbage Collection)機制Java
- 垃圾收集機制(Garbage Collection)批判 (轉)
- Java教室: Garbage Collection 清除物件的順序 (轉)Java物件
- 【原創】【Android】揭祕 ART 細節 ---- Garbage collectionAndroid
- 從ASP.NET Core 3.0 preview 特性,瞭解CLR的Garbage CollectionASP.NETView
- 淺談PHP5中垃圾回收演算法(Garbage Collection)的演化PHP演算法
- Java常見知識點彙總(⑰)——垃圾回收機制(garbage collection-GC)JavaGC
- ☕[JVM技術指南](3)垃圾回收子系統(Garbage Collection System)之垃圾回收器JVM
- Garbage Collection 一直在執行? 還是需要時才啟動? (轉)
- sort-based shuffle的核心:org.apache.spark.util.collection.ExternalSorterApacheSpark
- leetcode [python] 【338】Counting BitsLeetCodePython
- Python演算法:Counting 101Python演算法
- ☕[JVM技術指南](2)垃圾回收子系統(Garbage Collection System)之常見的垃圾回收演算法JVM演算法
- ☕[JVM技術指南](4)垃圾回收子系統(Garbage Collection System)之G1垃圾收集器SATBJVM
- GCD CountingGC
- ☕[JVM技術指南](1)垃圾回收子系統(Garbage Collection System)之回收標記和物件引用的介紹JVM物件
- ref
- 計數排序 - Counting Sort排序
- vue --ref用法Vue
- ref屬性
- ref和reactiveReact
- 【Lintcode】1736. Throw Garbage
- Spring中ref local=""與ref bean=""的區別SpringBean
- Laravel CollectionLaravel
- Collection介面
- Rust 中 *、&、mut、&mut、ref、ref mut 的用法和區別Rust
- Automatic Reference Counting-SwiftSwift
- React ref的用法React
- examples for oracle ref cursorsOracle
- 使用 ref 引用值
- Java集合-CollectionJava
- backup site collection
- Metric Collection ErrorsError