lua-users home
lua-l archive

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


On Mon, Mar 17, 2014 at 9:41 PM, Rena <hyperhacker@gmail.com> wrote:
> s = ('xxxxxxxxxxxxxxxx'):rep(99999999):rep(99999999):rep(99999999)
>
> This not only consumes a lot of memory, but because nearly all of the time
> is spent in string.rep, debug hooks won't be called either (the entire
> function call is a single Lua operation)

This is why it's useful to disable the string metatable temporarily.
See the 'paranoid' mode of pretty.load:

https://github.com/stevedonovan/Penlight/blob/master/lua/pl/pretty.lua#L72

(note also the ugly and rather slow lexical scan needed to weed out
loop constructs - hence the data mode patch)