diff --git a/src/box/lua/info.c b/src/box/lua/info.c index 96253734bf91fe7405526b6f9f61d87d3288f71f..19fa752f056ea2e82567dae1a2ba278027a4486a 100644 --- a/src/box/lua/info.c +++ b/src/box/lua/info.c @@ -411,7 +411,7 @@ lbox_info_memory_call(struct lua_State *L) lua_settable(L, -3); lua_pushstring(L, "lua"); - lua_pushinteger(L, G(L)->gc.total); + lua_pushinteger(L, luaL_getgctotal(L)); lua_settable(L, -3); return 1; diff --git a/src/box/lua/slab.cc b/src/box/lua/slab.cc index 309d2b1f55743e9d1455299fc7513ff5457993f0..e128b0ade0023967c6c82eafecdddf14178ed394 100644 --- a/src/box/lua/slab.cc +++ b/src/box/lua/slab.cc @@ -259,7 +259,7 @@ lbox_runtime_info(struct lua_State *L) * Lua GC heap size */ lua_pushstring(L, "lua"); - lua_pushinteger(L, G(L)->gc.total); + lua_pushinteger(L, luaL_getgctotal(L)); lua_settable(L, -3); luaL_pushuint64(L, tuple_runtime_memory_used()); diff --git a/src/lua/utils.c b/src/lua/utils.c index cccde3a912f153182ba9bf86d3468822abf17d6c..74d8544714a630b426143bdf7db01290f7bff89d 100644 --- a/src/lua/utils.c +++ b/src/lua/utils.c @@ -337,6 +337,12 @@ luaL_setcdatagc(struct lua_State *L, int idx) lua_pop(L, 1); } +size_t +luaL_getgctotal(struct lua_State *L) +{ + return (lua_getgccount(L) * 1024ULL) + lua_gc(L, LUA_GCCOUNTB, 0); +} + /** * A helper to register a single type metatable. */ diff --git a/src/lua/utils.h b/src/lua/utils.h index c07ab103183ef81fa7d6acd89c65b5c7b6279dfe..9fb97002cb569895f41e0567c0013b7ec45f5759 100644 --- a/src/lua/utils.h +++ b/src/lua/utils.h @@ -201,6 +201,13 @@ luaL_checkcdata(struct lua_State *L, int idx, uint32_t *ctypeid); LUA_API void luaL_setcdatagc(struct lua_State *L, int idx); +/** + * @brief Return size of currently allocated memory. + * @param L Lua State + */ +size_t +luaL_getgctotal(struct lua_State *L); + /** * @brief Return CTypeID (FFI) of given СDATA type * @param L Lua State