For this past few days I’ve working on a small game. However, I just noticed today that whenever I test it in studio and in-game, the game will crash after a few minutes. I never had this issue before, and I’ve had more crashes in this game today than I ever had this year.
I assumed that my code had a memory leak somewhere, but I don’t have a good idea of what it looks like and how to detect one. I looked around the developer console and had no idea what to do with the memory information.
I also tried to delete any plugins I wasn’t using, if there was something intentionally breaking my game, but that didn’t help.
I would like to show code, but I don’t know where this problem is coming from. If there is anyone that could point me to the right direction, I would really appreciate it. I’ll provide any information that might help with finding the issue.
Memory leaks can be very easy to identify though very hard to find. To first identify if there is a memory leak in your game open up the developer console and go to the memory tab at the top and open the “Memory” drop down. This shows you a graph of the amount of memory usage over time, if you see that the memory only increases and never decreases or plateaus then you have a memory leak (note that fluctuation in memory is normal). Make sure you repeat these steps for both the client and the server.
Now comes the hard part, finding where the memory leak is occuring. When you first load into your game, check to see if the memory usage looks normal or not. If it does look normal then the memory leak is most likely occuring when you’re performing an action in your game and there is a connection being made. Start to perform random actions in your game and monitor the memory usage and check to see what actions are causing the memory leak.
There is also a very useful tab in Roblox Studio that can help you identify what script is causing the memory leak. If you go to View > Script Performance you can monitor how much % of memory a script is taking up.
Make sure you’re always disconnecting events that will just take up memory. For example:
Tool.Equipped:Connect(function()
Tool.Activated:Connect(function() -- This will linger around in memory forever! Make sure you disconnect it
print("Tool Activated")
end)
end)
Since this post, I’ve tested three times and it only crashed one time. It wasn’t crashing so frequently like before for some reason, and I haven’t touched the code.
I have no free model scripts in the game and I only have 6 plugins installed that I know are not malicious.
For the first test, I was looking at the client’s memory, and it was steadily increasing, from 300 MB to around 570 MB, until it flattened out. The server’s memory was around 200 MB and didn’t really change. When I some did some of the actions in the game, it didn’t seem to affect the memory.
But a couple of minutes after I closed the console it suddenly crashed.
The other two tests I did in studio and in-game were similar but it didn’t crash for some reason. I felt like I waited longer for nothing to happen than before.
I created a bunch of clicked events for all the click detectors I have. Is it necessary to disconnect that?
Seems a bit repetitive, how will that help? (and assumptions about what?)
You assume that every line that you write is doing exactly what you expect it to do.
It isn’t. The art to debugging is checking all your assumptions.
One of coarse checks the “for sures” last. That’s why it takes so long
The industry standard is 10 lines of error-free code a day…
If you are using PCalls you are not coding: Find that bug!
They just found a cuneiform from the oldest civilization known to man, Babylon. Took them a while to translate. Figured out that it is a Trig table WAY MORE accurate than the one we use today. Why? Because they used Base 60 (Like a clock); not Base 10. One has way more rational fractions. (Instead of only 1/2 & Int/5)
Written in stone; and no bugs…?!
Made me wonder: How many mathematicians trying to solve these million dollar prize equations, are trying to do it in Base 60…?
Hmm, I’m not really sure if this issue is occuring because of a memory leak because that sounds relatively normal. Can you keep the console open until your game crashes / freezes and then take a screenshot of what the memory usage graph looks like? Does this issue only occur in the Roblox client or does it also occur in Roblox Studio? Also, what do you mean by crashes, does the window freeze up and stop responding?
The “an unexpected error has occurred” pop ups every time it crashes, both on the client and in studio. But today I realized it had nothing to do with the game.
I crashed while playing a different game that I worked on, which meant that my client and studio has just crashing more often. Should I reinstall everything at this point?
I’ve tried reinstalling Roblox Studio two times and a number of other ways to fix this (clearing cache, checking drivers), but the crashes seemed to happen more frequently.
I would crash even when I’m not testing the game. It has happened 4 consecutive times when I try to build.
The only solutions I could try is to close background apps like my browser, and have my battery run on “Best Performance”, but it does take more out of my battery.
I never remember my Studio crashing at all with my 7-year-old laptop (while having my browser on too), and I’m kind of confused why it’s doing this on my newer laptop. This is out of the scope of scripting help, but if anyone has a solution in mind, I would greatly appreciate it.
Hi, sorry to hear that Studio is crashing, it must be very frustrating/ When you reinstall Roblox Studio, do you clean out the original version and settings?
There is a folder under:
C:\User<you username>\AppData\Local\Roblox
Delete everything in there to remove any plugins and settings and then reinstall Client and Studio.
If that doesn’t work then remove the folder again and this time, also remove the Roblox Registry settings (proceed with caution):
Are you still getting crashes in Studio then? Do you have any plugins loaded? If yes, then try disabling them.
The crash report you are getting looks to be specific to Roblox Studio and not a Windows version. However, Windows may have logged some info about it. open Computer Management to find out. The next time it crashes:
Click Start > then type Computer Management
Right-click the icon and select Run As Administrator
Enter the password for Admin account (you aren’t logging in as Admin are you, cos I hope not)
Navigate to Event Viewer > Windows Logs > Application
This will show you what applications have been up to, errors and general information that they report to Windows. I don’t know if Roblox specifically logs to here, but it might do, hence why you should try looking here after Studio crashes. I managed to find a crash from RobloxPlayerBeta.exe from back in May in my logs, so hopefully you might see something.
If it doesn’t, then wee can look at the native Studio logs:
Open Explorer, navigate to C:\Users<your user>\AppData\Local\Roblox\Logs
Sort the list by Data by clicking on the Date Modified or Date Created heading\
Check for the most recent Studio log file, scroll to the end and see the heck it is up to.
There is no guarantee it will show anything, but I think it might log the crash info here as that error looks like a Studio native dialog box.
Yup, I’ll see if disabling all my plugins help, but I’m pretty sure they aren’t the reason why studio crashes, because I also crash when I’m just playing games.
EDIT: I've also successfully crashed studio without any plugins enabled.
But the first digits of the crash ID is different from the one below.
Crash ID: c2130000-4e51-7d07-0000-000000000000
I found a crash ID in my most recent studio log, and other lines of text about the crash.
Hi, saw your comment on the other thread. Ironically it started to happen to me a few weeks ago after a Team Create session ended abnormally. Following my advice to you above, did not fix the problem.
To resolve it, I removed all traces of Roblox Client & Studio from Disk, then went through the Registry and found all Keys & Value pairs that matched the word “roblox”. This fixed my problem completely.
It’s drastic, comes with warnings (take a backup of the Registry first) and has it’s risks, but the reward was high. The alternative solution is to reinstall Windows which is just time consuming.
No, not place files. Just any files under C:\Users<you acct name>\AppData. Remember that the AppData folder is hidden, so you may need to change to options in Explorer > View Options to “Show hidden files & folders”