Skip to content

Commit

Permalink
Unbind references from container on scene unload
Browse files Browse the repository at this point in the history
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.

modesttree#246
  • Loading branch information
villetuh committed Dec 28, 2022
1 parent 28d01ed commit f0625be
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ protected override void Awake()
}
}

protected virtual void OnDestroy()
{
_container.UnbindAll();
}

#if UNITY_EDITOR
protected override void ResetInstanceFields()
{
Expand Down

0 comments on commit f0625be

Please sign in to comment.