-
Mayank Mittal authored
# Description In Python, memory management is based on reference counts, where an object isn't "truly" deleted if it has variables referring to the memory address. More details: https://www.pythontutorial.net/advanced-python/python-references/ In Orbit code, we provide "self" to various callbacks, which increments the reference counts since they "refer" to the object. This means that when we do: ```python robot = Articulation(cfg=ANYMAL_C_CFG) ``` The reference count is 3: one for the `robot` variable and two for the callbacks we launched on separate threads. Now, if we try to delete the object by doing `del robot`, the reference count becomes 2. These correspond to the callbacks that were launched. However, the destructor `__del__()` isn't called yet because it is only done when all the reference counts are 0. As a fix, this MR uses a proxy weak reference to "self" when passing it to underlying callbacks or other classes. This does not increment the reference count for the object; thereby, when the main object is deleted, all ts proxy references become invalid as well. ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Checklist - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./orbit.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file
| Name |
Last commit
|
Last update |
|---|---|---|
| .github | ||
| .vscode | ||
| docker | ||
| docs | ||
| source | ||
| .dockerignore | ||
| .flake8 | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| LICENSE | ||
| README.md | ||
| VERSION | ||
| orbit.sh | ||
| pyproject.toml |