FIXED: [win11 td 2022.29850] Garbage collector acts weird

Hey, this is more of a feeling rather than reproduceable bug, but I feel like object destructors are not called properly. I saw similar complaints before but there people also weren’t able to pinpoint it to something particular. In the attached toe I at least have one repeatable problem: when you have a list of objects if you then set this list to an empty list (effectively deleting the only reference to the object) then the garbage collector isn’t called on objects that were contained in that list. If you call list.clear() however the objects destroyed properly.
Also I couldn’t reproduce, but when I was creating this “memory leak” when I was trying to print a list of referrents to that object I would get a giant list of built-in touchdesigner methods alongside some credits even :slight_smile:
The reason I’m concerned is because I have some big data structures and a notion of “show” in my patch, so when I switch “shows” around I want previous data to be properly garbage collected, but this doesn’t happen for the reasons I cannot yet understand.
I hope this is helpful somehow…
memtest.toe (5.3 KB)

Hey @densi

Can you describe what you are seeing in that .toe file you attached ?

Unless I misunderstood one of your points, it works as expected on my end:

The previous Foo objects get their destructor called every time I re-init.

Is it not what you are seeing ? Or is it not what you expect to see ?

Best,
Michel

I think that when you press third button “No garbage collect” - it is supposed to garbage collect the objects, because I’m setting Foos attribute of the parent to an empty list [], so basically there’s nothing pointing to foo objects anymore, so they should be garbage collected. I can confirm this behaviour in pure python file, but not in TD.

Ah ok yes, I see the point. Thanks for the sample.

Let me check with the team and we’ll get back to you.

Best,
Michel

2 Likes

Yep this is very weird!!! We’ll dig in this week

1 Like

We’ve located the problem and will have a fix in builds 2022.30960 and later.
Cheers

1 Like