Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

想问一下,在Python 环境下连接dolphindb时,调用toDF函数会自动释放内存吗,一下两种写法在内存使用上是否有区别?
1.

t = trade.select(cols).where()
df = t.toDF()

2.

df = trade.select(cols).where().toDF()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
504 views
Welcome To Ask or Share your Answers For Others

1 Answer

在trade.select(cols).where().toDF()中,toDF返回的是一个pandas DataFrame,而select和where都是中间计算,执行完之后,只要不将它赋值给一个变量,就会自动释放。

而在t = trade.select(cols).where() df = t.toDF() 中, t会保留在内存中,只有当t的引用计数变成0的时候,比如将另一个值赋给t,内存才会自动释放。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...