Skip to content

Commit c105fef

Browse files
anonymous2585Anonymous
andauthored
Fix some leaked managed shell (#1095) (#1096)
Co-authored-by: Anonymous <[email protected]>
1 parent ef2094a commit c105fef

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

org.mixedrealitytoolkit.input/InteractionModes/InteractionModeManager.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,17 @@ private void Awake()
298298
InitializeInteractionModeDetectors();
299299
}
300300

301+
/// <summary>
302+
/// A Unity event function that is called when the script component has been destroyed.
303+
/// </summary>
304+
private void OnDestroy()
305+
{
306+
if (InteractionManager != null)
307+
{
308+
InteractionManager.interactorRegistered -= OnInteractorRegistered;
309+
}
310+
}
311+
301312
/// <summary>
302313
/// A Unity Editor only event function that is called when the script is loaded or a value changes in the Unity Inspector.
303314
/// </summary>

org.mixedrealitytoolkit.spatialmanipulation/BoundsControl/BoundsCalculator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ internal static Bounds CalculateBounds(
100100
finalBounds.Encapsulate(root.InverseTransformPoint(totalBoundsCorners[i]));
101101
}
102102

103+
totalBoundsCorners.Clear();
104+
childTransforms.Clear(); // Avoid keeping reference to Unity objects to avoid "Leaked Memory Shell"
103105
return finalBounds;
104106
}
105107

org.mixedrealitytoolkit.uxcore/Interop/UGUIInputAdapter.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,19 @@ protected override void OnDisable()
162162
}
163163
}
164164

165+
/// <summary>
166+
/// A Unity event function that is called when the script component has been destroyed.
167+
/// </summary>
168+
protected override void OnDestroy()
169+
{
170+
base.OnDestroy();
171+
if (InteractionManager != null)
172+
{
173+
InteractionManager.interactorRegistered -= OnInteractorRegistered;
174+
InteractionManager.interactorUnregistered -= OnInteractorUnregistered;
175+
}
176+
}
177+
165178
/// <summary>
166179
/// Called when a an <see cref="IXRInteractor"/> is registered with a Unity <see cref="XRInteractionManager"/>.
167180
/// </summary>

0 commit comments

Comments
 (0)