Every runtime-created UStaticMesh adds never-freed FNames (`GetLODPathName`, RHI buffer labels): FName overflow in long-running non-Shipping builds

Version: UE 5.8.4 (also 5.7.4); the code is the same on ue5-main. Linux, Vulkan. Development game and editor.

Summary: FStaticMeshLODResources::InitResources (StaticMesh.cpp) creates FNames from each mesh’s name and path for debugging and resource tracking. For assets that’s a bounded set. But a mesh created at runtime (procedural content, streamed 3D map tiles) has a new, auto-numbered name and path, so every such mesh adds new FName strings. FName strings are never freed, so an app that keeps creating and destroying meshes eventually fails with:

Assertion failed: CurrentBlock < FNameMaxBlocks [File:./Runtime/Core/Private/UObject/UnrealNames.cpp] [Line: 870]
FName overflow, allocated 1024MB of string data. FName strings are never freed and should be created sparingly.

Two sources, both in non-Shipping builds:

  1. UStaticMesh::GetLODPathName() (with RHI_ENABLE_RESOURCE_INFO):
    return FName(FString::Printf(TEXT("%s [LOD%d]"), Mesh ? *Mesh->GetPathName() : TEXT("UnknownStaticMesh"), LODIndex));
    
    One name per mesh, about 120 bytes each, e.g. /Engine/Maps/Entry.Entry:PersistentLevel.Actor_2147482393.StaticMeshComponent_2147464392.StaticMesh_2147464391 [LOD0].
  2. The NameRHIResources buffer labels (!(UE_BUILD_SHIPPING || UE_BUILD_TEST)): <mesh name>_IB, _VB, _TC, _TB, _CB, bound with BindDebugLabelName, each becomes a new FName. In a packaged game runtime objects are numbered from one global counter, so every mesh name is new (StaticMesh_2147464394_CB): five more names per mesh. (In the editor, meshes owned by different components are all StaticMesh_0, so the labels repeat there.)

Steps to reproduce with GitHub - bringert/ue-mesh-fname-repro: UE 5.8 repro: every runtime-created UStaticMesh adds never-freed FNames (FName overflow) · GitHub (UE 5.8, one game mode, no plugins or content):

  1. Build and run it: UnrealEditor MeshFNameRepro.uproject -game -ExitAfter=600, or package it as Development and run that.
  2. It creates a one-triangle UStaticMesh 10 times a second (NewObject<UStaticMesh>(Component), BuildFromMeshDescriptions), each on its own registered UStaticMeshComponent, and destroys the oldest component once 50 are alive. Every 10 s it prints the FName count and, from 30 s on, groups the names added since then (FName::DebugDump()).

Results (UE 5.8.4, Linux/Vulkan, 600 s, 5,700 meshes after the 30 s baseline):

Build New FNames per mesh <mesh path> [LOD0] buffer labels
editor -game 5,700 1 5,700 0
packaged Development 34,204 6 5,700 28,500

The live UObject count stays flat. In our app (Cesium for Unreal streaming 3D Tiles, one mesh per tile primitive; CesiumGS/cesium-unreal#1926), a packaged Development game reached 1 GB of FName strings in 6.9 h.

Expected: debug and resource-tracking names for transient runtime meshes shouldn’t accumulate forever.

Suggested fix for GetLODPathName:

FName UStaticMesh::GetLODPathName(const UStaticMesh* Mesh, int32 LODIndex)
{
#if RHI_ENABLE_RESOURCE_INFO
	if (Mesh && !Mesh->IsAsset())
	{
		return NAME_None; // runtime meshes: unique paths would fill the FName table
	}
	return FName(FString::Printf(TEXT("%s [LOD%d]"), Mesh ? *Mesh->GetPathName() : TEXT("UnknownStaticMesh"), LODIndex));

Tested with UE 5.8.4 built from source (tag 5.8.4-release) with the attached repro in editor -game, 600 s each, 5,700 meshes after the baseline: stock, 5,700 new FNames (all [LOD0] paths); with this change, 0. (Also tested on 5.7.4 from source with our Cesium-based repro: 2,779 [LOD0] names in 14 min stock, 0 with the fix.)

The buffer labels could likewise be skipped for non-asset meshes in NameRHIResources, or kept as plain strings by the RHI instead of FNames. Alternatively, GetLODPathName could return a non-interned string for RHI resource info.