mlua icon indicating copy to clipboard operation
mlua copied to clipboard

Access `used_memory()` from `set_interrupt()` callback

Open 33KK opened this issue 3 years ago • 1 comments

Discussed in https://github.com/khvzak/mlua/discussions/196

Originally posted by 33kk August 2, 2022 I need to cap memory usage of the lua context, so I am trying to check current memory usage in interrupt handler since set_memory_limit is not available with Luau. Using an Arc<Mutex<Lua>> doesn't work either since it doesn't drop the lock while executing code.

33KK avatar Aug 02 '22 23:08 33KK

The reason why I skipped &Lua from interrupt callback arguments is because of unclear status of interrupts. Not all operations are permitted inside callback. But there is no list of banned operations too :( Unfortunately I forgot about possibility of capturing outer variables which still allow to get access to Lua state. I don't have yet a clear solution. Ideally only a few operations should be permitted (like calling used_memory).

khvzak avatar Aug 02 '22 23:08 khvzak