Memory leaks, memory leaks seemingly everywhere!
Or maybe it’s just the one source rearing its ugly head all over the place (oh please be the case). You know when you ignore a problem and hope it goes away but it doesn’t… then it instead gets worse? Perfect then you understand exactly how I got here.
I swear I’m not lazy; I’m just clueless
So, I’d like to clear up some memory leak(s), but I don’t know where it’s(they’re?) coming from. As a prerequisite just know that I did in fact look at community tutorials “PSA: Connections can memory leak Instances!” by Stravant. As well as “Garbage Collection and Memory Leaks in Roblox - What you should know” by Hexcede. I think they’re done fantastically, but unfortunately even with that knowledge it doesn’t seem to apply to the scripts, or perhaps I’m misunderstanding or maybe even missing something?
As I understand from those tutorials, what applies to the scripts is only Connections that don’t break. There are occasions where certain objects that don’t get duplicated, cloned, etc. that you interact with never get disconnected. Since I always want you to be able to interact with some buttons, it doesn’t make sense to me as to why I would disconnect them. Otherwise other connections are made for cloned objects, but they are later Destroyed.
Instead Now, I ask of you
With how the memory leak(s) present itself(themselves), could you help me figure out what kind of script would be the issue? I have for you, how the memory leaks are presenting themselves.
To Start:
as you can see in the PhysicsParts in the CLIENT SIDED Memory usage only continues to climb. “What causes this,” you ask? Well, strangely enough, resetting. Resetting your character will cause PhysicsParts memory to steadily rise.
This is the result of resetting around twenty times:
You can see from the first and second image CLIENT SIDED PhysicsParts went from around 100 to 320.
The large image with the graph and the smaller one without are both from the same session. Now what you’re telling yourself is probably along the lines of “Well that could be anything, how am I supposed to know,”
Aha! well another clue:
The Circled number goes up by 10,000
This is also in the same session as the previous two, and I will also show a (low quality) video that demonstrates what I’m trying to show in this picture a little better. Now unlike the previous two images I don’t really know what this means. Since, in a baseplate that number is approximately 181,000, so I assume it doesn’t actually indicate the number of instances. This one may be irrelevant information due to me not understanding it, apologies.
Perhaps in a different vein, there is also another issue
Third:
The CLIENT SIDED LuaHeap memory usage steadily increases.
After about half an hour the LuaHeap steadily climbs from 300 to 400. Unlike the PhysicsParts this does not appear to be influnced by anything other than time and the occasional script that appears to clean itself up, like the large jump you see in the picture.
Finally, I have a video that demonstrates the instance increase as well as one final way the memory leak(s) present itself(themselves).
The worst way possible:
The SERVER SIDED UntrackedMemory goes up when you reset
This is done on a private server. The rest of the examples are from the same session.
(Sorry for the quality and speed, the 10MB requirement is rigid.)
What I try to demonstrate is that the instances on the left hand side go up by 10,000, and worst of all, as well as what seems to be the biggest issue, Untracked Memory increases. Even worse, is it doesn’t happen every time, but heavily impact servers. Also, when a player leaves the game the UntrackedMemory also goes up by around 40MB. Unlike like all the other examples I’ve shown, this one seems to lead to a dead end and is the least diagnosable, but is also the most impactful on the game.
If you look here:
SERVER SIDED UntrackedMemory gets giant. It can be as large as 5000 on older servers(12hours)
“Where’s the code so we can help?” you may be asking. Well not only would it be bad idea for me to post all the code for the game, it would also be too much to reasonably ask someone to look though out of the kindness of their heart. Instead I thought maybe people could help me actually find the code that needs fixed based off of the information provided. (I’m desperate and don’t know what to do other than ask for help) Then once the kind of code that could be causing issues is found
I have some slight hunches, but after reviewing the code, disabling parts of the script to see if it would stop the issue, I didn’t have much luck. I’ve messed with quite a few things but didn’t do the best record-keeping on what results were. So if anyone has any questions that could help you help me I’ll happily answer them. My hope is once I can identify one of the memory leaks I can spot the rest of them.
To Close:
Horomori will also be assisting me in finding this issue. They may be more interactive as they are much more knowledgeable in scripting than myself and are more qualified in answering your questions, but I’ll do what I can.
Thank you for reading, and I’ll get all my thanks out in advance for your future assistance as well. I appreciate it as I feel I’ve of hit a wall.
Oh also here’s the game if that helps: Fling Things and People