summaryrefslogtreecommitdiff
path: root/server/src/service.lua
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-04-12 15:30:28 +0800
committersumneko <sumneko@hotmail.com>2019-04-12 15:30:28 +0800
commit9297dd189945e8019c4598ad3eb082059ab4a3e7 (patch)
tree80ad977e95d5af0068db23d2b8016ba6cb444c7e /server/src/service.lua
parent2d0a488eb5a871d6f70b3c6288c9c650b6689655 (diff)
downloadlua-language-server-9297dd189945e8019c4598ad3eb082059ab4a3e7.zip
统计并回收子线程的内存
Diffstat (limited to 'server/src/service.lua')
-rw-r--r--server/src/service.lua18
1 files changed, 16 insertions, 2 deletions
diff --git a/server/src/service.lua b/server/src/service.lua
index ade3b2eb..f14b0a9b 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -750,9 +750,20 @@ function mt:_testMemory()
end
local mem = collectgarbage 'count'
+ local threadInfo = async.info
+ local threadBuf = {}
+ for i, count in ipairs(threadInfo) do
+ if count then
+ threadBuf[i] = ('#%03d Mem: [%.3f]kb'):format(i, count)
+ else
+ threadBuf[i] = ('#%03d Mem: <Unknown>'):format(i)
+ end
+ end
+
log.debug(('\n\z
State\n\z
- Mem: [%.3f]kb\n\z
+ Main Mem: [%.3f]kb\n\z
+ %s\n\z
-------------------\n\z
CachedVM: [%d]\n\z
AlivedVM: [%d]\n\z
@@ -769,6 +780,7 @@ function mt:_testMemory()
TotalLoc: [%d]\n\z
TotalVal: [%d]\n\z'):format(
mem,
+ table.concat(threadBuf, '\n'),
cachedVM,
aliveVM,
@@ -791,7 +803,9 @@ end
function mt:onTick()
self:_loadProto()
self:_doCompileTask()
- if os.clock() - self._clock >= 60 and not self:isWaitingCompile() then
+ if (os.clock() - self._clock >= 60 and not self:isWaitingCompile())
+ or (os.clock() - self._clock >= 300)
+ then
self._clock = os.clock()
self:_testMemory()
end