Skip to content

Releases: rfortier/JContainers-rwf

Remove 2GB restriction in lua, especially important for big builds or Skyrim Together Reborn

28 Jul 16:38
Compare
Choose a tag to compare

Replacing 4.2.13 release. Functionally equivalent, adds timeout to wait-for-memory loop that should never hit with a gc64 luajit compile.

Finish conversion of JContainers64.dll to the x64 address model. This entails adding "gc64" to the build instructions for luajit to remove the restriction that luajit could only allocate memory from the first 2GB of the virtual address space.

64-bit address space support is considered beta in the current luajit version 2.1.0-beta3.

The fix entails 2 parts. The first is a change to lua_module.cpp to check for the failure of luaL_newstate() and retry every second until it works. Without this check, when no memory below 2GB is available on large builds, you get a CTD from reopen_if_closed() when loading a save. With this fix it won't crash, but it can take several minutes before a big enough chunk of memory is available below 2GB to continue.

You could still encounter a crash later on other allocations that aren't protected, though.

The complete fix involved compiling luajit with the gc64 flag to remove the restriction that allocated memory had to be below the first 2GB.

The problem is particularly bad if you use the Skyrim Together Reborn mod, which changes the memory layout to load it's own logic. A modest build with STR, JContainers, AH Hotkeys (requires JContainers) and a big inventory is enough to provoke the problem (which is why I hunted it down and fixed it).