Does the table have performance limits?

I generate a voxel space and set each point to a value that needs to be saved. I use a table for this. But when I exceed the grid size value of more than 300
(27,000,000 voxels in table), the loop starts lagging and throws a wait error.

local Table = {}
for x = 0, 300, 1 do task.wait()
    for y = 0, 300, 1 do
        for z = 0, 300, 1 do
              Table[VectorStringName] = {...}
        end
   end
end

By the end of the cycle, it starts running slower and slower, and then a waiting error pops up. What can be done to optimize such huge arrays?

just for some background, what are you using this for

Custom voxel system. It works exactly the same way as Terrain from roblox. Only on EditableMesh

I need to record and save millions of voxels somewhere. 27 million is still working, but if more than that, then everything breaks

best thing to do is instead of having one huge table, is to use chunks and split the tables up

i had a voxel system and what i did was for every new chuck i added a folder and placed a module inside of the folder and all my voxel data for that chunk went inside of that module

1 Like

I started doing it. But it seems that my knowledge wasn’t that good, and I just divided them into fragments and put them in one table. XD
Thank you, I understand that it is best to use a separate script module to store the table.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.