Commit 4df117fbb4323c90ef97a121f0117f425e1eadb0
1 parent
0c5a281a
添加定时gc功能
Showing
1 changed file
with
7 additions
and
0 deletions
Show diff stats
src/agent.lua
| ... | ... | @@ -35,10 +35,17 @@ local function handle_timeout() |
| 35 | 35 | skynet.timeout(100, handle_timeout) |
| 36 | 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 | 44 | function start_agent_timer() |
| 39 | 45 | if agentInfo.open_timer then return end |
| 40 | 46 | agentInfo.open_timer = true |
| 41 | 47 | skynet.timeout(150, handle_timeout) |
| 48 | + skynet.timeout(6000, handle_gc) | |
| 42 | 49 | end |
| 43 | 50 | |
| 44 | 51 | function cancel_agent_timer() | ... | ... |