Locating memory leaks?

I’m having difficulty on finding what is causing a memory leak in my game. If you guys have any information how i might be able to figure out where its coming from that would be great. BTW most of memory is coming from Default and Untracked.

2 Likes

Generally, memory leaks are caused by leftover code that doesn’t get picked up by the garbage collector and it gets left in the memory. You should check throughout your code to optimize it and disconnect any connections you don’t need or use the :Destroy() method to properly remove the object from memory if you don’t need it.

I’m by no means an expert on this type of stuff, but there is a wonderful tutorial that explains in-depth what could cause some of your leaks.

https://devforum.roblox.com/t/psa-connections-can-memory-leak-instances/90082

11 Likes

I’m just going to add on as this is the first result on google.

Roblox’s F9 Menu gives you all the tools you will need, you can see whats taking up memory under LuauHeap.

Unique references will let you know all the instances that are held by a script but are not parented to anything (very common for invisible mem leaks!) and tells you the script’s name. It even tells you the line number. This will also include active connections.

We found out the server was still holding on to old player characters that disconnected AGES ago.
We finally got our servers to stay up for up to 48 hours, before we could only do ~18 before it crashed.

We also found out we have over ~3000 number values existing in our game at a given point :sob:

20 Likes

This is actually so helpful and great. Bumping this.

1 Like

Bumping this because of how helpful it is