sync_traits creates reference cycles.
- Dominant language
- Python
- Stars
- 462
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
The `sync_traits` method on `HasTraits` objects creates reference cycles. In the script below, the `create_cycles` function creates two cycles that won't get collected until the cyclic garbage collector runs. See the attached image for the details of the cycles.
```
import gc
import refcycle
from traits.api import HasStrictTraits, HasTraits, Instance, Str
class Eggs(HasStrictTraits):
spam = Str
class Sandwich(HasStrictTraits):
spam = Str
def create_cycles():
sandwich = Sandwich()
eggs = Eggs()
sandwich.sync_trait('spam', eggs)
def main():
gc.disable()
gc.collect()
create_cycles()
garbage = refcycle.garbage()
print "garbage: ", garbage
with open('garbage.gv', 'w') as f:
f.write(garbage.to_dot())
if __name__ == '__main__':
main()
```

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.