mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
move skynet.memlimit from skynet.manager to skynet
This commit is contained in:
@@ -656,6 +656,11 @@ function skynet.term(service)
|
|||||||
return _error_dispatch(0, service)
|
return _error_dispatch(0, service)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function skynet.memlimit(bytes)
|
||||||
|
debug.getregistry().memlimit = bytes
|
||||||
|
skynet.memlimit = nil -- set only once
|
||||||
|
end
|
||||||
|
|
||||||
local function clear_pool()
|
local function clear_pool()
|
||||||
coroutine_pool = {}
|
coroutine_pool = {}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ function skynet.abort()
|
|||||||
c.command("ABORT")
|
c.command("ABORT")
|
||||||
end
|
end
|
||||||
|
|
||||||
function skynet.memlimit(bytes)
|
|
||||||
debug.getregistry().memlimit = bytes
|
|
||||||
end
|
|
||||||
|
|
||||||
local function globalname(name, handle)
|
local function globalname(name, handle)
|
||||||
local c = string.sub(name,1,1)
|
local c = string.sub(name,1,1)
|
||||||
assert(c ~= ':')
|
assert(c ~= ':')
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ init_cb(struct snlua *l, struct skynet_context *ctx, const char * args, size_t s
|
|||||||
size_t limit = lua_tointeger(L, -1);
|
size_t limit = lua_tointeger(L, -1);
|
||||||
l->mem_limit = limit;
|
l->mem_limit = limit;
|
||||||
skynet_error(ctx, "Set memory limit to %.2f M", (float)limit / (1024 * 1024));
|
skynet_error(ctx, "Set memory limit to %.2f M", (float)limit / (1024 * 1024));
|
||||||
|
lua_pushnil(L);
|
||||||
|
lua_setfield(L, LUA_REGISTRYINDEX, "memlimit");
|
||||||
}
|
}
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
local skynet = require "skynet"
|
local skynet = require "skynet"
|
||||||
require "skynet.manager"
|
|
||||||
|
|
||||||
-- set sandbox memory limit to 1M, must set here (at start, out of skynet.start)
|
-- set sandbox memory limit to 1M, must set here (at start, out of skynet.start)
|
||||||
skynet.memlimit(1 * 1024 * 1024)
|
skynet.memlimit(1 * 1024 * 1024)
|
||||||
|
|||||||
Reference in New Issue
Block a user