UntrackedMemory spikes when destroying models, doesn't go back down

Came across today when I was trying to find some memory leaks in my game. In the video below, you can see I have many cars lined up. Please note that these are only car models, and there are no scripts in them. There are 0 scripts in the workspace; just the models are in the workspace. Then, you can see I clone the car folder two times. Lastly, I destroy all the folders containing the cars.

The UntrackedMemory value spikes after deletion of these folders, and never goes back down. I’ve been on the plate for a few minutes, and it never showed any sign of returning to normal. Garbage collection works near instantly, if not instantly, so it should go back down as soon as I destroy them.

At first, it seemed like a garbage collection-related memory leak since it was under “Untracked”. However, 0 scripts are referencing the cars (as I mentioned before, it is only the car models in the workspace; there are absolutely 0 scripts in the workspace). The only script that gets close to it is the main script I show at the beginning and end of the video. However, I cleared the reference to the folders in the loop after destroying them, and there is nothing in LuauHeap to signify otherwise as well.

I believe the spike becomes larger when there are welds and scripts inside the vehicles as well. To limit any variables, though, I destroyed them, so it’s just the car model being tested.

Video:

Here is a testing plate so you can test yourself. The car models in this plate are just toolbox models, instead of the ones in the video, but they produce the same result as the video.
UntrackedMemory Testing.rbxl (2.6 MB)

10 Likes

I can confirm I’m experiencing the same issue (in other games too)

4 Likes

Not sure if related, but a similar memory issues as discussed above is occurring to a multitude of experiences.

Client memory performance stats for one of my games (no changes or updates to the experience in weeks):

One large experience (Dress to Impress) seems to be experiencing a drop in play time, and many other top experiences:

3 Likes

I can confirm that I am also experiencing this.

2 Likes

UntrackedMemory in this situation is just memory freed and returned to pool to use for future allocations.

Unless there is actual unbounded increase of the value over time, the UntrackedMemory value is not an issue.

1 Like

The problem is that UntrackedMemory increases when cars for example get destroyed, and when alot of cars get spawned and destroyed it gets to the servers memory limit.

The original posters game, Lawcountry, is suffering from repeated crashes which makes it loose players. The number #1 contributor to the total memory is UntrackedMemory.

3 Likes

I think that it’s because when destroying models, all of the memory used by the model (scripts, textures, properties etc…) are “untracked” which means that the pointer to the car memory is destroyed but not the data itself. It goes then to untracked memory for future models to use (that’s why when you duplicate models, untracked memory decreases). It’s like a pool of memory

If you destroy the pointer to the heap memory then it becomes a memory leak; from what I remember, its just a block of memory, that instead of being freed its reused, improving performance somewhat, if your algorithm just goes all in and doesn’t balance it correctly, your bad, its like std::vector, which when you add items and it runs out of space, it automatically allocates a new block twice as big as the last one, and copies all elements, which might seem wasteful, but then, imagine you just add ONE object, and you call .push_back several times, then you will be constantly resizing and copying data, leading to an absurd performance loss.

I mean, the block of data that was used, when it’s deleted, the data just stay there waiting for some new data to be overwritten on top i think

This problem exists for years but roblox does nothing

My game has also been having problems with memory, and I haven’t been able to find the cause of it.
The memory usage seems to continue to increase the longer the server runs, causing many players to lag even with an empty server. With a full server, it’s x10 worse.
My game also frequently generates and destroys models(horses). This bug would provide an explanation to this problem.
image