Exposing the GC Estimate Value to the API

This commit is contained in:
LeonTheo02 2024-09-14 05:11:40 +02:00
parent 87ae18af97
commit e48198b77e
No known key found for this signature in database
GPG Key ID: 83C6193480CF6EBD
2 changed files with 4 additions and 0 deletions

View File

@ -1297,6 +1297,9 @@ LUA_API int lua_gc(lua_State *L, int what, int data)
case LUA_GCISRUNNING:
res = (g->gc.threshold != LJ_MAX_MEM);
break;
case LUA_GCESTIMATE:
res = (int)(g->gc.estimate >> 10);
break;
default:
res = -1; /* Invalid option. */
}

View File

@ -228,6 +228,7 @@ LUA_API int (lua_status) (lua_State *L);
#define LUA_GCSETPAUSE 6
#define LUA_GCSETSTEPMUL 7
#define LUA_GCISRUNNING 9
#define LUA_GCESTIMATE 10
LUA_API int (lua_gc) (lua_State *L, int what, int data);