Hello, guys. I’m making mining game.
Today, I though I finished mining system - I did infinite mine generation, ores, some ways to dig.
But when I opened Performance stats, I understood that my mine is far-far from finishing.
(I was testing in studio, because of new Roblox byfron, so can’t test in Roblox Player)
Blank baseplate in studio, uses around 2k mb memory
But when I looked in my mine game, I understood that my system uses TOO much memory:
And that 3k Mb is just spawning, not counting that player will move, and load new chunks:
4.4K MB IN UNDER THAN MINUTE!
(IDK, is studio counts memory used by “Server”)
Now some things about my system:
- It uses chunk system. Each chunk is cube 16x16x16 blocks.
- Block is always part with size 1x1x1 stud.
- Chunks are generating on server, but only if:
- player send request to load chunk(-s);
- cave requested to load certain chunk;
- Client unloads chunk, if it too far from it, with:
MineSystem[X][Y][Z] = nil
- Server unloads ALL chunks exept chunks near players once every 15 minutes
So I think this memory primarly from server, because I don’t unload anything from it for 15 mins. Because if player will go from point A to point B, unload chunks at A, and then went back to it, player will expect to see everything that was before.
And now I realized that I need do something with this absurd memory usage, or everyones devices will run out of memory (or roblox servers xd).
Can someone tell me please, what I can do, to decrease memory usage?
P.S.
After looking at Dev Console, I found that Instances use only 80 mb
Most memory used by LuaHeap and Script (800mb and 300mb respectively)
Also, A lot of memory is “Untracked” - 800 mb