Apparent memory leak in RecastJS


We’re tracing down an occasional crash that occurs in a long-running session. When it occurs, the Babylon scene freezes (but HTML overlays remain functional) and the console reports:

Uncaught abort(OOM), Build with -s ASSERTIONS=1 for more info with a code location that points to RecastJS.

To investigate, I started a scene and then, after loading and initial stabilization, I ran Chrome’s memory allocation timelines tool, which is designed to troubleshoot memory leaks by identifying objects that remain in memory without getting garbage collected for long periods of time.

The results show Vec3 objects from recast.js are continuously allocated and remain in memory for at least 5 minutes.


Here’s how we’re using Recast in our render loop:

const newCameraPositionXZ = navigationPlugin.moveAlong(
const newCameraPosition = navigationPlugin.getClosestPoint(

This is one part of our never-ending quest to help Frame run better on Safari, @Cedric :cold_face:

But yeah, this does also freeze MY machine and I’m on an absolute beast i9 and rtx 3090 etc.

Say no more! I’m on it! Thank you for invaluable investigation!

1 Like

PR is live : [Navigation] Limit new objects for garbage collection by CedricGuillemet · Pull Request #10301 · BabylonJS/Babylon.js · GitHub

1 Like

This is awesome, thank you @Cedric . Looking forward to trying this out!

1 Like

Let me know if it works for you. I did this change blindly as it’s the only place I found that allocated Vec3.


Hey @Cedric we’re pretty sure this problem is resolved, thanks! After your patch, Recast’s memory footprint is completely flat and we haven’t observed the crash.


@Cedric, GG

1 Like