lua-users home
lua-l archive

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


Hi,
We're developing a console game that uses Lua and wanted to find out any memory saving tips people might have.

Currently Lua uses more memory than we would like (close to 5MB). When I looked into the memory allocations incurred by Lua, I was surprised at the volume. We have over 40,000 allocations. I created a test project to load a single script with no code inside.

This caused the following allocations:

72 bytes by LoadFunction > luaF_newproto
32 bytes by LoadString (seems to be the name of the file? in this case "Boot") 21 bytes by LoadString > luaS_newlstr (seems to be the name of the script? in this case also "Boot")
4 bytes by LoadLines
4 bytes by LoadCode
24 bytes by luaF_newLclosure

Is this correct? Is there a way to suppress things like the line number, etc.?

Once I start putting code inside the scripts, I see a similar pattern of allocations for each line of code (or couple of lines of code? not sure what causes more memory to be allocated). Any tips to help reduce the runtime memory would be appreciated.

Thanks,
Brett