Skip to content

Commit 6597e40

Browse files
author
Anonymous
committed
Fix some leaked managed shell (#1095)
1 parent 4f5b465 commit 6597e40

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
@@ -319,6 +319,17 @@ private void Awake()
319319
InitializeInteractionModeDetectors();
320320
}
321321

322+
/// <summary>
323+
/// A Unity event function that is called when the script component has been destroyed.
324+
/// </summary>
325+
private void OnDestroy()
326+
{
327+
if (InteractionManager != null)
328+
{
329+
InteractionManager.interactorRegistered -= OnInteractorRegistered;
330+
}
331+
}
332+
322333
/// <summary>
323334
/// A Unity Editor only event function that is called when the script is loaded or a value changes in the Unity Inspector.
324335
/// </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
@@ -164,6 +164,19 @@ protected override void OnDisable()
164164
}
165165
}
166166

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

0 commit comments

Comments
 (0)