The leaking variable is UInstancedStaticMeshComponent::InstanceDataBuffers.
The memory block is passed to InitPerInstanceRenderData() via InstanceDataBuffers.Release(). But the function doesn't manage the passed memory block.
Following workaround works.
void UInstancedStaticMeshComponent::OnPostLoadPerInstanceData()
{
if (!HasAnyFlags(RF_ClassDefaultObject|RF_ArchetypeObject))
{
// create PerInstanceRenderData and pass InstanceDataBuffers ownership to it
#if 0
InitPerInstanceRenderData(true, InstanceDataBuffers.Release());
#else
InitPerInstanceRenderData(true, InstanceDataBuffers.Get());
#endif
}
// release InstanceDataBuffers
InstanceDataBuffers.Reset();
void UHierarchicalInstancedStaticMeshComponent::OnPostLoadPerInstanceData()
{
...
if (!bForceTreeBuild)
{
// Create PerInstanceRenderData either from current data or pre-built instance buffer
#if 0
InitPerInstanceRenderData(true, InstanceDataBuffers.Release());
#else
InitPerInstanceRenderData(true, InstanceDataBuffers.Get());
#endif
NumBuiltRenderInstances = PerInstanceRenderData->InstanceBuffer_GameThread->GetNumInstances();
InstanceCountToRender = NumBuiltInstances;
}
// If any of the data is out of sync, build the tree now!
BuildTreeIfOutdated(bAsyncTreeBuild, bForceTreeBuild);
}
}
InstanceDataBuffers.Reset();
}
InstancedMesh LLM counter keeps increasing.
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-109898 in the post.
| 0 |
| Component | UE - World Creation - Worldbuilding Tools - Foliage |
|---|---|
| Affects Versions | 4.25 |
| Target Fix | 4.27 |
| Created | Mar 3, 2021 |
|---|---|
| Resolved | Mar 19, 2021 |
| Updated | Nov 30, 2022 |