support sandbox memory limit

This commit is contained in:
Cloud Wu
2016-05-06 23:40:44 +08:00
parent 76d1e6fa1f
commit 4b96ade660
3 changed files with 44 additions and 7 deletions

18
test/testmemlimit.lua Normal file
View File

@@ -0,0 +1,18 @@
local skynet = require "skynet"
require "skynet.manager"
-- set sandbox memory limit to 1M, must set here (at start, out of skynet.start)
skynet.memlimit(1 * 1024 * 1024)
skynet.start(function()
local a = {}
local limit
local ok, err = pcall(function()
for i=1, 1000000 do
limit = i
table.insert(a, {})
end
end)
skynet.error(limit, err)
skynet.exit()
end)