LuauHeap incorrectly shows the same path for all Unique References, effectively hiding the location of most paths

LuauHeap’s Unique References tab is not properly showing all places where an Instance reference is being kept alive.
There are multiple paths shown, but all of them incorrectly have the same content.

Example

Below is a screenshot of my repro place. There are five unique Listener scripts holding onto a reference for this part, and there are five “paths”, but all of them incorrectly say that Listener2 is the sole problem.

Notice how Listener2 is repeated 5 times. The expected behavior, in this specific instance, would be that it shows Listener(1, 2, 3, 4, 5) instead of just Listener2.

Repro

Here’s a minimal-case repro that does the following:

  • Spawner script spawns a part, then destroys it after one frame.
  • 5 Listener scripts listen to this part being spawned, and purposely leak a reference to it by adding it to a table that’s never cleaned.
    Luauheap Repro.rbxl (56.0 KB)

Repro Steps

  1. Enter a playtest on the above game
  2. Wait until all 5 of the listeners signal they’ve seen the part
  3. Open up the LuauHeap tab, switch to server view, and look at unique references
  4. Notice only one of the scripts is being signalled as holding onto the part

Info & Impact

This happens in both Studio and live games.
I am on Windows 10.
I don’t know when this started happening. My best guess is sometime in the past month.
This is making debugging very hard; I’d have to fix all stale references one at a time and restart playtest for each one, hoping I fixed it, instead of being able to pick-and-choose (or do all of them at once).

Expected behavior

I expect Unique References to not show the same path for all of the possible paths.

1 Like

Thank you for the report.

While we were able to find an issue with different paths not being explored correctly, the fix will not improve the report in your example.

To save memory, we have to cache scripts with identical bytecode copied around in different places of the DataModel.
This can display as scripts in different locations all having the same ‘source’ reference.
So in your example, paths come from 5 different instantiations of the function, which are different objects in memory.

We have a fix ready for the same path being printed for different scripts, but unfortunately, we do not plan to fix ‘different’ scripts having the same source string.

One recommendation we would like to make is to look into CollectionService | Documentation - Roblox Creator Hub
While we try to detect identical scripts to not have copies of the same memory around, there is still overhead to having a Script instance in every object.
Using the CollectionService you can restructure your project to only have a single script.
Not only will it save memory and can make management of object behaviors easier, it will side-step the problem with identical-looking paths in the Luau Heap snapshots.

What inspired me to create this report was something I perceived to be different scripts reporting as the same one.


(not shown in this screenshot, but all of the paths report coming from the same thing)

I only have one instance of Adonis ingame, and this was masking a leak somewhere else in another unique script (one that serves an entirely different purpose). This game has no duplicated scripts in the same vein as my repro. Multiple scripts, yes, but they all serve different purposes, and certainly no duplicated bytecode.

Will your changes fix this situation?

Yes, your original case should be fixed.

Thank you for providing a minimized example, we changed it a bit to avoid the duplicate bytecode source issue and see the problem.

1 Like

Fix has been released on Server, Desktop Client and Studio.
With more users adopting an updated release, the fix will also appear on mobile platforms.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.