I've seen Lua use up to 150K or RAM while a script is running - this is on top of the 100K needed to load the Lua module (if you use 1.2) and the memory needed to load the script code.
The garbage collector will eventually reclaim it; but if you are severely memory limited it can run out.
The camera CHDK has over 1MB free RAM at start. The script is running in no-shoot mode, 1...2s/cycle, AF lock. Free memory (as displayed by the script) shows decreasing tendency (GC periodically reclaims most memory, but not all), and eventually Lua encounters an out of memory situation. I have already seen something similar, when I was testing remote shooting on the ixus870_sd880. Putting more pause between shots helped there, haven't tried that on this cam.
This sounds like there is a memory leak somewhere. In my tests there was no significant increase in memory over 10k shots.
The "mem" lines produced by my modified version of the script are.
lua allocation in KB (from collectgarbage('count')) followed by free mem from get_meminfo (in bytes)
These are also logged as Alloc and free
From one of my 10k shooting runs, start was
Alloc: 57 free: 373960
and the end was
Alloc: 76 free: 346784
In between, lua allocation bounced around between ~125 and ~60
The script is pretty garbage happy (it creates a lot of unique strings) but the collector appears to keep up. This shouldn't vary between cameras much, although differences in shooting times could lead to more or less stuff being logged.