Description

When destroying an Actor with a Procedural Mesh Component; that is stored in an Array Variable, the memory for that Actor's Procedural Mesh Component is not cleared, leading to a Memory Leak. However, If you make the actor into a Single Variable and destroy it, that Procedural Mesh's memory is properly cleared by Unreal's Garbage Collection.

Steps to Reproduce

NOTE: See attachment  "MemoryLeak_Example.zip"  for simplified project source replication. 

 

Open Unreal Engine 4.20-> Create Third Person Blueprint Template.

Creating Procedural Mesh Actor

  1. Inside of Content Folder-> Create a new Blueprint Actor class. "TestActor"
  2. Inside of Blueprint Actor-> Add Component-> Procedural Mesh
  3. Inside of Blueprint Actor->Construction Script-> Create new local variable
  4. Name local Variable "Vertices" and choose Vector Array for Variable Type->Compile.
  5. Populate the Array with 8 elements, set the vector coordinates as shown in attached file: ProceduralMeshActor.png.
  6. Create a local Variable "Triangles", and choose Integer Array for Variable Type->Compile.
  7. Populate the Array with 36 elements, set default values as shown in attached file: ProceduralMeshActor.png

Creating a new Blueprint Player Controller

  1. Create a new Blueprint Player Controller
  2. Inside of Player Controller Blueprint-> Create a new variable called "Chunk Test Array" of type "TestActor", and make it an Array->Compile.
  3. Inside of Player Controller Blueprint->Create a new variable of type integer, named "MeshIDs"->Compile.
  4. Drag off of the event tick node of the Player Controller event graph, and implement the following. (see attached file: PlayerControllerEventGraph.PNG) 

Playing in Editor

  1. Create a new Blueprint Game Mode.
  2. Change Player Controller class to PlayerController Blueprint.
  3. Change Default pawn class to ThirdPersonCharacter.
  4. Go to Project settings->Maps&Modes-> Choose Gamemode_Bp for Default Game mode.
  5. Open up Windows Task Manager to monitor memory usage.
  6. Play in Editor
       

Expected: The Memory used by the Procedural Mesh Component is cleared when the Actor is destroyed.

Result: The memory usage of Unreal Engine will keeping going up while you play until your computer runs out of memory and the game/editor crashes. The actor is successfully destroyed, yet the memory taken by the mesh geometry is still remaining.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-65234 in the post.

4
Login to Vote

Cannot Reproduce
ComponentUE - Gameplay
Affects Versions4.194.204.21
Target Fix4.22
CreatedOct 15, 2018
ResolvedDec 11, 2018
UpdatedDec 12, 2018
View Jira Issue