Open lin-hitonami opened 1 year ago
For this specific issue, the memory leak comes from pytaichi.global_vars
which holds a expr_field
corresponding to the place-SNode of the field. Upon SNodeTree destruction, the cached expr_field
won't get poped from the global_vars
, resulting in the memory leak.
The bigger issue is that there's no lifetime management for the global variables associated with PyTaichi, therefore similar memory leak will still appear if we only fix this single issue. I'd suggest fixing this PR along with the Type System Refactor, where we can implement a more systematic mechanism to manage the global variables & caches at Python scope.
Describe the bug The memory increases when running the snippet below by ~5KB/iter. From https://forum.taichi-lang.cn/t/topic/3839 To Reproduce