Lua Table Memory?
Asked Answered
T

1

5

This might be sort of a strange question, but curiosity got the best of me when I ended up getting a memory error after filling up a table with 14 million+ items.

Is there a sort-of set memory limit for Lua tables, or is it somewhat dynamic at all? I figured Lua itself would allocate so much memory in general, and the error would be thrown when that ran out, but that's just a wild guess. Anyone know for sure? Thanks.

Tver answered 10/7, 2013 at 18:54 Comment(3)
I have no sources, but as far as I know, Lua will take as much memory as it needs and can get. However, array-table allocation is to the power of 2, so you actually had an array-table with 14m items, it actually was 2^24 longHydrostatics
Source: lua.org/gems/sample.pdf page 19Hydrostatics
What error message did you get?Ypsilanti
M
7
t={}
for i=1,176000000 do t[#t+1]=i end

Tried out with a lua windows 64 bit binary - works fine.

a large lua state

A 64 bit luajit binary crashed. Seems like a bug of luajit.

Magdalenmagdalena answered 11/7, 2013 at 6:49 Comment(2)
after 4gb lua64 bit stopped growing the table gracefully with a message not enough memoryMagdalenmagdalena
here's a reference that lua tables are subject to 4gb memory limit. In the source: max size of array part is 2^MAXBITSMagdalenmagdalena

© 2022 - 2024 — McMap. All rights reserved.