Why is my memory so high?


Genuinely feel like my game is pretty optimized, not the best it could be, but it’s decent. I only have 1 big while loop in the whole game which handles everything, I also connect events in one module and call all the needed functions from there.

I have 37 “remotes” (by remotes I mean bindable events, bindable functions, remote events, remote functions, unreliableremoteevents, etc)

I don’t think there’s that many memory leaks? Atleast ones that grow overtime because it’s pretty consistent.

My game is pretty complex with queues, matchmaking, server wide games, inventories, shops, client side mechanics, etc. But even then I see that Rivals uses almost 2x less memory than my game

2 Likes

High memory? Try this:

  • Use collectgarbage("count") to track usage.
  • Avoid constant loops and reloads.
  • Watch asset caching and remotes.

Test in chunks to spot the culprit.

2 Likes

check for raycasts you may create and not clear in any loop

2 Likes

How do you clear raycasts? Also any suggestions for what to replace remote events with? Heard of ByteNet and other services but not sure which is best. I don’t know if that has to do with memory but the game sometimes feels clunky in general.

1 Like

basically with raycasts what you want to do with them is reusing raycasts you already created and not make new ones with each function

network libraries like fastnet, bytenet and etc are usually used in large scale projects and mostly useless for smaller (less than 30-50 remotes used per minute), so it would be easier for you to just optimize event usage

1 Like

I’ve heard of fastnet and bytened and tried using bytenet but couldn’t figure it out, so I made my own module, which just directs all networking activities to 5 networking objects (RemoteEvent, BindableEvent, RemoteFunction, BindableFunction, UnreliableRemoteEvent) depending on what is called.

Is this essentially what these other services do?

Try

  • Removing all SmoothTerrain
  • Huge meshes, too

And comparing it to the default baseplate. It’s probably not a script.