Mathijs-Bakker / Extenject

Dependency Injection Framework for Unity Game Engine
MIT License
531 stars 97 forks source link

Unbind references from container on scene unload #71

Closed villetuh closed 1 year ago

villetuh commented 1 year ago

Zenject doesn't properly clear reference from scene container when scene is unloaded. This results in memory leak when loading and unloading scenes.

Fixed the issue by unbinding all reference from scene container when SceneContext component is destroyed.

Thank you for sending a pull request! Please make sure you read the contribution guidelines

Pull request checklist

Please check if your PR fulfills the following requirements:

Pull request type

Please check the type of change your PR introduces: - [x] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## Issue Number

Issue Number: 246 in Zenject repository

https://github.com/modesttree/Zenject/issues/246

What is the current behavior?

What is the new behavior?

Does this introduce a breaking change?

Other information

-

On which Unity version has this been tested?

Scripting backend:

Note: Every pull request is tested on the Continuous Integration (CI) system to confirm that it works in Unity.

Ideally, the pull request will pass ("be green"). This means that all tests pass and there are no errors. However, it is not uncommon for the CI infrastructure itself to fail on specific platforms or for so-called "flaky" tests to fail ("be red"). Each CI failure must be manually inspected to determine the cause.

CI starts automatically when you open a pull request, but only Releasers/Collaborators can restart a CI run. If you believe CI is giving a false negative, ask a Releaser to restart the tests.