Hello there. Recently I’ve come out with a new game and a lot of complaints have been coming in claiming that it is very laggy for mobile devices. My game is not optimized AT ALL as I’ve never done this before. Since I’m new I didn’t really know where to start. I used the developer console to track the amount of memory being used and to try to check what’s causing it. I did a couple of tests and tried deleting mass areas to see if it would lower the memory usage so I knew what areas/things were causing this. However nothing seemed to lower the usage. I’ve tried researching better ways to be able to tell what exactly the problem is but nothing seems to be able to tell me what exactly I need to change. Does it really just come down to common sense? Change lighting, get rid of excessive parts, etc? Or is there a way to be able to pinpoint what’s causing the mass usage for an easier fix?
Also some feedback on my scripting, I have 2 scripts, 1 on the server and 1 on the client. There’s currently about 5000 lines of code for both. I use these scripts to track/call events. I’m not sure if this is the best way to do this but it’s easier to have everything in 1 script versus multiple other scripts that hold events.
There should be a selector to view stats for physics, rendering etc separately this would give you some idea of where any overheads might be. Also checking the client and server separately will help.
I think much of it is pretty obvious. Lots of unanchored parts will slow physics, whereas lots of overlapping transparencies and awkward geometries will slow rendering. Same with effects, long distance views, atmospherics, particles etc.
Having just 2 scripts with 5k lines sounds awkward to maintain (modulescripts are best for compartmentalising code). Are you making use of thread spawning or coroutines? Do you use loops frequently? Is there any big calculations taking place? Are there points at which the code is waiting for something (not necessarily for long, but frequently)? Are you cleaning up connections that are no longer needed?
Just some things to think about. There are a few good community tutorials on memory leaks which might help, I’ll post them if I can find them again!
In fact search the forum for “Optimisation” in #resources#community tutorials, there are a whole range of in depth articles.
Thanks for replying! Firstly I moved all physical parts from ReplicatedStorage to ServerStorage. The 2 scripts does sound awkward, but it’s much needed. The way my game works is having random events. So there’s a loop to randomly fire an event from storage. The reason why it’s 5k is because it’s full of the event functions. I’m not even sure any other way to handle this. I’m going to try getting rid of some Unions as I heard they’re horrible for your game