From fe7b7bd71785844dd34aea9e2a1da9f8b9e6620a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 12 Mar 2019 18:12:44 +0800 Subject: =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=80=E4=B8=8Bvm=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E4=BB=A5=E4=BE=9B=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/vm/vm.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'server/src') diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 841b09ca..88a272de 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -1171,6 +1171,22 @@ local function compile(ast, lsp, uri) return vm end +-- TODO 测试代码 +local CachedVM = setmetatable({}, {__mode = 'kv'}) + +local function checkCachedVM(vm) + CachedVM[vm] = true + local total = 0 + local alive = 0 + for vm in pairs(CachedVM) do + total = total + 1 + if not vm:isRemoved() then + alive =alive + 1 + end + end + log.debug(('持有的VM:%d/%d'):format(alive, total)) +end + return function (ast, lsp, uri) if not ast then return nil @@ -1179,5 +1195,6 @@ return function (ast, lsp, uri) if not suc then return nil, res end + checkCachedVM(res) return res end -- cgit v1.2.3