mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
add cmemory.info() returns a table of c memory info
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <lua.h>
|
||||
|
||||
#include "malloc_hook.h"
|
||||
#include "skynet.h"
|
||||
@@ -224,3 +225,17 @@ skynet_lalloc(void *ud, void *ptr, size_t osize, size_t nsize) {
|
||||
return skynet_realloc(ptr, nsize);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
dump_mem_lua(lua_State *L) {
|
||||
int i;
|
||||
lua_newtable(L);
|
||||
for(i=0; i<SLOT_SIZE; i++) {
|
||||
mem_data* data = &mem_stats[i];
|
||||
if(data->handle != 0 && data->allocated != 0) {
|
||||
lua_pushinteger(L, data->allocated);
|
||||
lua_rawseti(L, -2, (lua_Integer)data->handle);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user