Commit 8c154e114068df7f135b18ba49f74058ed38ce63
1 parent
e3f6fe34
定时gc
Showing
2 changed files
with
8 additions
and
1 deletions
Show diff stats
src/agent.lua
@@ -35,10 +35,17 @@ local function handle_timeout() | @@ -35,10 +35,17 @@ local function handle_timeout() | ||
35 | skynet.timeout(100, handle_timeout) | 35 | skynet.timeout(100, handle_timeout) |
36 | end | 36 | end |
37 | 37 | ||
38 | +local function handle_gc() | ||
39 | + if agentInfo.open_timer then return end | ||
40 | + collectgarbage("collect") | ||
41 | + skynet.timeout(6000, handle_gc) | ||
42 | +end | ||
43 | + | ||
38 | function start_agent_timer() | 44 | function start_agent_timer() |
39 | if agentInfo.open_timer then return end | 45 | if agentInfo.open_timer then return end |
40 | agentInfo.open_timer = true | 46 | agentInfo.open_timer = true |
41 | skynet.timeout(150, handle_timeout) | 47 | skynet.timeout(150, handle_timeout) |
48 | + skynet.timeout(6000, handle_gc) | ||
42 | end | 49 | end |
43 | 50 | ||
44 | function cancel_agent_timer() | 51 | function cancel_agent_timer() |