Game keeps crashing in studio and in-game

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.

5 Likes

You probably have either a malicious script/plugin or some while true do loop in your game, replace while true do with while task.wait() do in future.

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)
2 Likes

What errors are you getting?

If you aren’t getting any; make your own: Put a print, pretty well every-other line; printing out the value you changed in the previous line.

One or more of your assumptions are wrong.

Tip: The one value that you are absolutely sure is not giving you problems is the odds on favorite to have a bug.

1 Like

Check for any scripts you didn’t make on purpose. I have a feeling this is a virus from a freemodel.

1 Like

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?)

Thank you everyone for the help though.

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…?

1 Like

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?

1 Like

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):

  1. Click Start > Run, type “regedit” and click OK
  2. Navigate to HKEY_CURRENT_USER > SOFTWARE > Roblox
  3. Delete all keys/settings in that folder
  4. Reinstall Roblox Studio

Hopefully, that solve the issue.

1 Like

Thank you for the help but removing the Roblox registry settings didn’t work.

When I checked for the Roblox folder under the local app data, it wasn’t there, so I assumed it was already removed when I uninstalled it.

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:

  1. Click Start > then type Computer Management
  2. Right-click the icon and select Run As Administrator
  3. Enter the password for Admin account (you aren’t logging in as Admin are you, cos I hope not)
  4. 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:
  5. Open Explorer, navigate to C:\Users<your user>\AppData\Local\Roblox\Logs
  6. Sort the list by Data by clicking on the Date Modified or Date Created heading\
  7. 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.

Merry Christmas and a Happy hunting to you.

1 Like

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.

Crash ID: 20130000-4e51-7d07-0000-000000000000

Merry Christmas to you too!

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.

1 Like

Does this include all the local place files for Studio?

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”

1 Like

I’ve opened the registry editor and made a backup.

Are these folders/keys what I need to delete?

keys

If you press “F3” the Find menu should open. Just enter the word “roblox” and allow it to search. Remove all instances that you find.

Be careful not to accidently remove any other Keys as it can damage your system.

1 Like

Hi, I got around to deleting everything related to Roblox in the registry, and whenever I play a game I still experience crashes.

I still haven’t tried out Studio yet, but I’m afraid that it will be the same case.

But, since it worked for you, I’ll mark this thread as solved because it might help other people experiencing the same issues.

Thank you for the help though, I really appreciate it.