Memory leak when player respawns

My client memory usage is usually around 1350 to 1500 mb.
image

Also, after a bit of digging in LuaHeap, I found that each reset, the “thread” object increases in size and count. I don’t know exactly what this means though. What I’m thinking is that somewhere in my scripts a thread isn’t being closed. Is there a way to find out where this is happening?

Anything below 2000mb shouldn’t concern you, that’s actually quite good. Only raise concerns of memory if it goes over 2000mb

I understand that, but the problem is that I’m worried that memory will continue to pile up to the point where it goes over 2000 mb, making the game laggy and unplayable.

I also noticed the object “enumitem” gradually increasing. I don’t really know why enum items are increasing. Are they variables in a script or something?

My memory is about 1600-1700 when I am playing with 3-4 players, but I see other games with 20-30 players with 1200-1300 mb. I think I’m doing something wrong with my code.

The problem is that my luaheap memory stays constant while my total memory (graph) increases and doesn’t come down. This makes it almost impossible (at least that’s what I know of) to find out what is causing the leak.

Using events rather than loops is preferable, when possible. It would reduce the amount of Tweens being created, although to be honest, if health is changing very frequently, then there wouldn’t be that much of a difference between using loops

I don’t think that the tweens are responsible for the memory leak, now that I have a better understanding on how you’re using them

Another thing you should check is to make sure that you aren’t creating a connection which isn’t disconnected inside of another connection, that would definitely result in a memory leak


@himynameisKyliee2007 By the way, is the memory leak occuring when testing on the Player? If it isn’t, then it’s relatively safe to ignore, although do check on the Player again from time to time, and take note of the script so that you’ll remember where to look for the potential cause

Honestly I’ve came back to scripting after 4 months so i’m a bit rusty, this section of the docs may help:

It could be that the other games contain less content, eg you have more builds than them.