# Mass instanced skinned mesh sweep removes instances without freeing their ASTP tracks 

**URL:** <https://forums.unrealengine.com/t/mass-instanced-skinned-mesh-sweep-removes-instances-without-freeing-their-astp-tracks/2851430>\
**Category:** Character & Animation\
**Tags:** unreal-engine, Epic-Pro-Support, question\
**Created:** [October 5, 2026, 10:42pm UTC](https://forums.unrealengine.com/t/mass-instanced-skinned-mesh-sweep-removes-instances-without-freeing-their-astp-tracks/2851430 "2026-10-05T22:42:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [October 5, 2026, 10:42pm UTC](https://forums.unrealengine.com/t/mass-instanced-skinned-mesh-sweep-removes-instances-without-freeing-their-astp-tracks/2851430/1 "2026-10-05T22:42:37Z")

</div>

Could this go to Melyssa Battison please, cc Mieszko Zielinski? It is in the instanced skinned mesh update in UMassVisualizationComponent.

When an entity stops being batched into an instanced skinned mesh component, the “Collect unwanted items & remove” sweep removes its instance, but never frees its ASTP track. Only ProcessRemovesForComponent calls DeallocateTrack, and outside the stationary ISM switcher and its destructor nothing in MassRepresentation calls RemoveInstance. So for a moving entity the sweep is the only way out of a component, and every despawn, LOD change or significance range change leaves a track behind.

The leaked track stays active, so it is still uploaded every frame, and it keeps its last sequence index. Once that sequence is released with DeallocateSequence, the ensure fires and the track is left pointing at a freed slot.

This is the non-external-ID path. The sweep is the same in //UE5/Main MassVisualizationComponent.cpp#74 (around line 951) and //UE6/Main #12 (around line 1069). We are on 5.8 with 57928894 and 58169258 cherry-picked from UE5/Main, which is where AllocateSequence and DeallocateSequence come from.

Locally I made the sweep free the track the same way ProcessRemovesForComponent does:

```auto
if (SharedIdMap.ContainsElementId(ElementId))
{
	FPrimitiveInstanceId InstanceId = SharedIdMap.GetByElementId(ElementId).Value;
	check(InstanceId.IsValid());

	const FMassEntityHandle SweptEntity = SharedIdMap.GetByElementId(ElementId).Key;
	const Experimental::FHashElementId TrackElementId = TrackMap.FindId(SweptEntity);
	if (TrackElementId.IsValid())
	{
		if (UAnimSequenceTransformProviderDataInstance* ASTPDI = Cast<UAnimSequenceTransformProviderDataInstance>(InstancedSkinnedMeshComponent->GetTransformProvider()))
		{
			ASTPDI->DeallocateTrack(TrackMap.GetByElementId(TrackElementId).Value);
		}
		TrackMap.RemoveByElementId(TrackElementId);

		const Experimental::FHashElementId AnimStateId = ResolvedAnimStates.FindId(SweptEntity);
		if (AnimStateId.IsValid())
		{
			ResolvedAnimStates.RemoveByElementId(AnimStateId);
		}
	}

	SharedIdMap.RemoveByElementId(ElementId);
	RemovedInstancedSkinnedMeshInstanceIds.Add(InstanceId);
}

```

With that in, plus a fix to our own batching, we no longer hit the ensure in a cooked Development build, with sequences freed after a 1 second grace period.

Is that how you would want it fixed, or would you rather the sweep go through ProcessRemovesForComponent?

We will take whatever lands upstream and drop ours.

Also, a smaller ask. The update path reads InstanceAnimationData[IDIndex] in step with EntitiesRequiringUpdate, so a caller that calls AddBatchedAnimationData for only some of the entities it batches transforms for silently shifts every later entity onto its neighbour’s animation.

That one was our bug, but an ensure that the animation array is either empty or the same length as the transforms would have caught it straight away.

Here is the ensure callstack:

```auto
ensureMsgf(Pool.GetData(TrackIndex).GetSequenceIndex() != SlotIndex, TEXT("ASTP: sequence slot %d released while set on track %d layer %d"), ...)
UAnimSequenceTransformProviderDataInstance::DeallocateSequence::<lambda_1>()
UAnimSequenceTransformProviderDataInstance::DeallocateSequence()
<game code releasing a runtime-allocated sequence once no entity references it>
FMassProcessingPhase::OnParallelExecutionDone()
...
UWorld::Tick()

```

[Attachment Removed]

---

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [October 5, 2026, 10:42pm UTC](https://forums.unrealengine.com/t/mass-instanced-skinned-mesh-sweep-removes-instances-without-freeing-their-astp-tracks/2851430/2 "2026-10-05T22:42:41Z")

</div>

**Steps to Reproduce**  
I have not isolated this into a template project, but it is all stock Mass and ASTP code. The sweep in our build is unmodified apart from the fix in the description.

1. Set up Mass entities with a SkinnedMeshInstance representation whose FMassSkinnedMeshInstanceVisualizationMeshDesc has a UAnimSequenceTransformProviderData as its TransformProvider. UMassVisualizationComponent gives each component its own UAnimSequenceTransformProviderDataInstance.
2. Drive them with UMassUpdateInstancedSkinnedMeshProcessor plus FMassRepresentationAnimationFragment and UMassConsumeInstancedSkinnedMeshAnimationProcessor, so each entity gets a track.
3. Make some entities stop being batched into that component: despawn them, LOD them to Actor or None, or move them to another significance range.
4. The “Collect unwanted items & remove” sweep removes their instances, but their tracks stay allocated and active, and their TrackMap and ResolvedAnimStates entries stay too. A track is only reused if the same entity comes back to that component, which a despawned one never does.
5. Play a sequence added at runtime with AllocateSequence, then release it with DeallocateSequence once no live entity plays it. If a leaked track last played it, a non-shipping build hits the “sequence slot %d released while set on track %d layer %d” ensure.  
[Attachment Removed]

---

<div class="post-metadata">

**Author:** ![DDeVoe](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ddevoe/32/1000886_2.png) [@DDeVoe](https://forums.unrealengine.com/u/DDeVoe)\
**Post date:** [October 7, 2026, 9:11pm UTC](https://forums.unrealengine.com/t/mass-instanced-skinned-mesh-sweep-removes-instances-without-freeing-their-astp-tracks/2851430/3 "2026-10-07T21:11:59Z")

</div>

Hey there,

I got it over to the dev you’ve asked for as a bug, you can follow it here: [https://issues.unrealengine.com/issue/UE-401320](https://issues.unrealengine.com/issue/UE-401320)

They agree that it’s an issue and they’re coming up with a plan for it. I’m getting some more context on your second question.

[Attachment Removed]

---

<div class="post-metadata">

**Author:** ![DDeVoe](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ddevoe/32/1000886_2.png) [@DDeVoe](https://forums.unrealengine.com/u/DDeVoe)\
**Post date:** [October 7, 2026, 9:22pm UTC](https://forums.unrealengine.com/t/mass-instanced-skinned-mesh-sweep-removes-instances-without-freeing-their-astp-tracks/2851430/4 "2026-10-07T21:22:42Z")

</div>

Regarding your second question, they’ll follow up as they address the issue; it will require some investigation.

[Attachment Removed]

---

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [October 6, 2026, 4:17am UTC](https://forums.unrealengine.com/t/mass-instanced-skinned-mesh-sweep-removes-instances-without-freeing-their-astp-tracks/2851430/5 "2026-10-06T04:17:13Z")

</div>

One more thing I noticed while fixing this. ResolvedAnimStates is keyed by entity only and shared by every skinned mesh component, but the sweep in EndVisualChanges (with our fix) and ProcessRemovesForComponent both erase it from inside a single component’s pass. So when an entity moves from one desc’s components to another’s in the same frame, the old component can erase the state the new one just wrote, depending on which component runs first. It should come back on the next update, so it is a one frame gap.

Nothing calls FindResolvedAnimState today so we see no effect, but it will bite whoever reads it next. Maybe only erase it once the entity has no instance left in any component, or keep the state per component?

[Attachment Removed]
