Version of mem that can be called from Lua code.