Game is super laggy and I'm genuinely at a loss on how to proceed

Hello!

I have released my game yesterday but I don’t know why but it is very laggy and I don’t know how to proceed. I have found that earlier levels are laggier than later ones and I simply cannot figure out why. Could it be the number of NPCs? I’m looking at the memory usage and a lot of the memory being used is from GraphicsTexture, I look up the URLs and it seems to be avatar textures. I’m afraid I have a memory leak or something and I really just don’t know how to proceed, I’m disconnecting old events and destroying instances which aren’t being used anymore.

If you want to try it out to give some suggestions, here’s the link:

The main issues are:

  • GraphicsTexture,
  • UntrackedMemory
  • LuaHeap

TIA for any help.

2 Likes

UntrackedMemory isn’t a problem iirc, its just unused memory roblox isnt deleting yet and has no impact on performance, it will be deleted as soon as its needed

As for the rest, I can look more closely at it later (I gotta go now) if I remember
Common sources of lag Ive found is like youre kinda hinting at, textures and decals
And also physics

2 Likes

The problem with UntrackedMemory is that it steadily increases. I have have been in-game for like an hour and it seems to go up above 500mb.

As for the decals, I’m using the in-game memory usage thing and these are what appear:

First is tx-shoes by Roblox,
Second is Korblox Deathspeaker,
etc…

I’m gonna try removing some of these NPCs and see if that helps.

Whatever changed between early and later stages can make an impact. Whatever you are doing or not doing in later stages is doing something. I would recommend looking at the amount of textures and meshes because those can cause lag. NPCs could impact performance.

I’m fairly certain NPCS are the issue. I’m looking towards and from the NPCs atm and it seems to be laggy when further away. Earlier levels are shorter and more condensed as well so that probably has an impact.

First, make sure anything unnecessary in the game is removed. Second, don’t use too many textures. Third, make sure there’s not a lot of infinite loops. (while true do) loops with no breaks or waits. This should help. (MAKE SURE SCRIPTS ARE NOT INSERTING PARTS.) This causes lag a lot of the time.

I think the issue was mainly NPCs, it seems to be reduced after I removed all of them. There are also some scripts cloning parts as if I didn’t have them, they wouldn’t be smooth, although there aren’t a lot of them.

If there are more than 2 clone scripts that do the same thing, put it into one. This is always a good practice. (Do the same thing like cloning the same part into 2 different clones, etc…)

There’s only one script creating new parts

Okay. And unionizing parts inside of NPC’s can also help if you want to keep NPC’s.

Wdym unionizing? I don’t really need the NPCs so it really isn’t too big of a deal.

So unionizing basically is “re-rendering” the parts into one. You simply grab all the parts in the NPC, and union them. Here’s a topic on it:

https://developer.roblox.com/en-us/api-reference/class/UnionOperation

Oh I see, I don’t really need NPCs as they don’t add too much to the game so it isn’t really a deal breaker for me. Thanks for the idea though.

Yes, and any model that has multiple parts that doesn’t need to be different parts, you can unionize to reduce lag.

It’s still occurring but I was able to cut down on lag a bit:

  • Removed all but 3 NPCs
  • Reduced amount of moving/physics parts
  • Changed lighting to compatibility (ew)

Do you have a “Humanoid” instance which isn’t parented? That can often cause a lot of lag.

1 Like

Nope, it seemed to be spinners for some reason. I wish it said that the memory leak was because of the physics parts, would have saved me a ton of pain haha