On 64-bit platforms, LuaJIT allows only up to 1-2GB of data (not counting objects allocated with malloc). Where does this limitation come from, and why is this
Due to recent patch luajit 2GB memory limit can be solved.
To test, clone this repo and build with LUAJIT_ENABLE_GC64 symbol defined:
msvcbuild.bat gc64
or XCFLAGS+= -DLUAJIT_ENABLE_GC64 in Makefile
I used this code to test memory allocation:
local ffi = require("ffi")
local CHUNK_SIZE = 1 * 1024 * 1024 * 1024
local fraction_of_gb = CHUNK_SIZE / (1024*1024*1024)
local allocations = {}
for index=1, 64 do
local huge_memory_chunk = ffi.new("char[?]", CHUNK_SIZE)
table.insert(allocations, huge_memory_chunk)
print( string.format("allocated %q GB", index*fraction_of_gb) )
local pause = io.read(1)
end
print("Test complete")
local pause = io.read(1)
Allocated 48GB before not enough memory error on my machine.