What is the largest size possible for a table?

The title says it all. Basically I want to know the biggest possible size for a table.

Lets say I am inserting something to the table every frame. What will be the limit for how big a table can get?

2 Likes

I don’t believe there is a limit. But I believe the more bigger it is the more memory you consume. So its more of a question of how efficient it is.

4 Likes

So it is based of the RAM / SSD space that the player / server has?

1 Like

Depends on the script.
Yes for Localscripts (as they run on the clients machine)
No for Scripts (as they run on the server so it would depend entirely on what server you got)

2 Likes

So if the table is stored on the localscript, then it is all based of how much space the client has, and what is being put into the table?

1 Like

Um, I guess kind of. I am not too sure on the situation, but if you consume too much ram the game may end up crashing. But its definitely better to stay on the safe side and find a more efficient solution.

@GreekForge Yeah, but even on the server, you should be cautious not to take up too much memory.

1 Like

Could you show me an example of an ‘Un-Efficient table’, and an ‘Efficient table’

I didn’t mean it exactly that way. I meant it as you should not try to push the limit. Try to keep your tables small or delete older and unneeded data. Programming is all about thinking up a path of steps to use to solve your problem. Most of the time, every situation has several solutions. Many of them are considered inefficient (using to much memory and lowers performance) while others are not. It takes time sometimes but you just have to think it through and figure out whats the best way to handle this problem.

So what exactly is your problem? Why do you need a huge table? Perhaps we can help you find a better solution.

3 Likes

That would be rather difficult without a scenario.
Generally if the table isn’t being added to continuously its fine.

It’s good practice to void a table when you’re done with it.

local array = {"Neat"}
array = {} --this is now voided (Now contains only nil, so no longer takes memory)
2 Likes

It will still get GC’d regardless, as long as it falls out of scope and without any other references.


Regarding OP, there’s not necessarily a set limit. Under the hood, Lua automatically resizes table allocation when needed (kinda like a List in C# or Java). You will eventually run out of memory (ram) of course. However, if you’re hitting that sort of limit, then you should redesign your system to avoid such large data sets.

6 Likes

What is GC’d?

30CHARACStersffs

GC stands for Garbage Collection. It’s basically a subsystem in a programming language that frees up memory from data that is no longer being used or referenced.

5 Likes

characters…

7 Likes

Oh I did not know that Lua will resize the table automatically, good to know. But yes I generally meant its not good at all if your hitting that kind of limit and a more efficient system should be used to avoid problems like this.

Thanks for the info.

1 Like