lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

We have a PS2 game that is in Beta and close to shipping now and I'm still having trouble tracking/controlling Lua's memory usage. Any tips would be greatly appreciated.

1. We use Lua 5.0.3 to script the entire game. Each script is an object that is loaded, run and collected individually as needed. We are loading a few hundred lua scripts for the non-game, once the player starts the game we unload all of these, and load a few hundred game scripts. Once game ends, reverse and repeat the process.

2. We do a memory dump from main menu, then run the game, then exit the game and do another dump from the main menu. Each time we do this cycle, memory associated with Lua has increased 145KB to 155KB. The things (quantity and exact items) being loaded both in game and out are fixed.

3. We do manual garbage collections after all unloads, prior to loads, and once again after the load has completed.

4. We have verified that the exact same objects are in memory at each snapshot.

5. We dumped the globals and registry tables and verified that the exact same keys are in lua at each snapshot.

6. The memory reported by lua as being in use doesn't change much (a few KB between runs).

7. Our internal memory manager traps all lua allocations and tags them so we know they are coming from lua. The increase in memory is memory used only. Fragmentation wouldn't effect the number.

8. Shutting down lua and restarting it isn't an option this late in the project.

Debugging Lua isn't the easiest thing I have ever done. If anybody can suggest any additional checks or debugging strategies it would be greatly appreciated.

Are there any code commentary docs anywhere that explain the internals of Lua?