LuaHeap and Navigation memory rising constantly at a rapid pace

After managing to finally get UntrackedMemory under control, I’ve notice that LuaHeap and Navigation memories are rising constantly at a rapid pace. It quickly becomes a serious problem as more and more major server lag and crashes reports come in. Both of them can sometimes rise above 1 GB. Can somebody explain what are they and how to get them under control?

Lua heap is regular memory allocations in Lua. Memory on the heap is memory allocated using the traditional malloc/calloc in C and is opposed to being allocated on the stack. It is called the LuaHeap because Lua manages the memory with its garbage collector. To reduce this, you have to let the garbage collector do its job. It only collects objects that no longer have references to them and therefore cannot be used again. You can think of your tables as a bunch of nodes pointing to each other. As soon as an island is formed separate from the environment table, that island may be collected.

I’m not sure what Navigation memory is, but I’d assume that is has to do with the pathfinding service. Do you use the pathfinding service?

Also, how long are your servers running?

2 Likes

It had only been running for an hour and both memory rose above 1 GB. No PathfindingService were used.

lol. I’m not on a Windows machine otherwise I’d pull up studio and test how hard it is to reach a 1GB heap in Lua. What type of game are you making, and what is using so much memory? I’ll really have to know more about your game to help you any more.

One thing I’d note is that some types of userdata (not lightuserdata) also count towards the LuaHeap memory. This means that Vector3’s, CFrames, ext may count toward it. Same for, parts / models as well. Again, I’m not sure which type of userdata they are so it would require some testing.

1 Like

It’s a game similar to Innovation Inc’s old lab. It has a massive part count of 35k currently but I don’t think it affects LuaHeap at all. I’ve already optimized the scripts for minimum UntrackedMemory production. But it doesn’t seem like it’ll help against LuaHeap and Navigation. They literally rises quicker than UntrackedMemory. Here’s the game: Eplison.Inc | Research Facility [ALPHA] - Roblox

What are your scripts doing? And do you have any suspects? One thing I’d try is disabling portions of the game (sets of related scripts) to see which subsystems are responsible for which portions of the memory leaks.

1 Like

Alright, thanks for the advice.