Debug slow / resource taking script

Hello,

I have a script in quite a big game which executes an action every second. It works nice in all other games, but not here, as one second legit takes a lwhile. You can see this with tweening too that there is an excessive amuont of lag.

I would like to know how I am able to detect which script is “eating” the resources. Is that possible, and if yes, how?

Thanks a lot in advance!

Regards,
Jonas

1 Like

There is indeed a way to detect the “resource eater”!
It is called the MicroProfiler. Simply press Cntrl F6 or Command F6 to open it up in Studio (you do not need to play the game, but it is also available in game). There, you can see how long a frame lasts, which process is contributing the most in terms of memory, resources, and time.

Here’s the DevHub article about it. There are also tutorial videos within it.
Hope that helps!

1 Like

Thanks a lot! That appears to be a very long frame there, which is most likely causing issues.

2 Likes

Just double checked, seems like it is for client debugging, but it’s eating server resources; Is there a tool for that too? :smiley:

2 Likes

I do believe there is one, I am not sure. Check the article, there should be info about that subject.

1 Like

I found this article:
https://developer.roblox.com/en-us/articles/Improving-Performance

Because you are struggling with server-side performance, I believe the Dev Console is your best bet:

I hope you find your problem!


Edit:
Perhaps this might even be useful:
https://developer.roblox.com/en-us/articles/game-testing


Edit 2:
If none of this works, I recommend collecting more data about your problem. Does it get worse over time, or is it constant? If it is the former, I’d suspect a possible memory leak and use the Lua Debugger to “Watch” your variables in a script. If it is the latter, then maybe a function is looping too much or is too intensive to complete in a short amount of time. Really jumping into your code can help you see problems from angles you weren’t looking from before. I hope you find your issue!

3 Likes