Dynamic navmesh and pathfind causes incremental framerate drop

Hi there,

If I set my navmesh to “Dynamic” or “Dynamic Modifiers Only” and then put a pathfind in the event tick of a blueprint I will see an incremental performance decrease over time until it suddenly shoots up to full framerate again. Which I guess is when garbage collection occurs.

Steps to reproduce:

  1. Blank project.
  2. Place a standard “Floor_400x400” static mesh at -500,-500,0 and scale it to 5,5,2
  3. Add a NavMeshBoundsVolume that covers the floor, and check that a RecastNavMesh is created properly.
  4. Set the RecastNavMesh runtime generation to “Dynamic” or “Dynamic Modifiers Only”.
  5. Open the SM_Chair asset and under Navigation, set its area class to NavArea_Obstacle and check the “Is Dynamic Obstacle” box.
  6. Create an Actor blueprint and add the newly modified SM_Chair asset to it.
  7. Add a “AddLocalRotation” node in the Event tick of the blueprint with delta rotation 0,0,1 and hook it up to the SM_Chair static mesh component. This is to force the navmesh to be recalculated every frame.
  8. Add a “FindPathToLocationSynchronously” node in the Event tick with path start set to 1300,1300,1 and path end -350,-350,1.
  9. Place the actor on the floor in the level so that it affects the navmesh.
  10. Hit run and use the console to show the navmesh and show the FPS. Make sure the navmesh is constantly updating and see how the framerate gradually goes down over time.

Is there any way to avoid this issue? A garbage collect seems to prevent the framerate from gradually decreasing, but it also prevents the game from running at any desired framerate. Is there a more selective garbage collect I can do, or perhaps another approach altogether?

This issue still exists, did you ever figure something out?

I haven’t touched that feature since I posted, so I don’t have an update I’m afraid. But I do have some kind of faint recollection of Epic updating the garbage collect feature so that it wouldn’t be spread out across multiple frames instead of just hogging the entire system all at once. But I haven’t tried it and could be wrong.

But to be honest, I think the only way of dealing with this is in a satisfactory way is to go into the code and rewrite the dynamic pathfinding feature so that it clears the cache with each new pathfind (or however you want it to work).

Ah, that sounds like a fair bit of work. I’m getting more acceptable performance by only finding paths on a 0.5 seconds timer, so I guess this will have to do for now. I really have to commend you on answering on a year post within half an hour though, that’s pretty swell of you.

1 Like

If a pathfind once every half second works for your game, then that could be a workable solution. With a low frequency like that, I don’t think the amount of paths in cache will ever reach a level that will affect performance too much before the built-in garbage collection clears it (every 90 seconds or so?).

No problem, I’m doing some pretty boring work at the moment so I jumped at the chance to do something else to be honest :slight_smile:

1 Like