hchunhui / librime-lua

Extending RIME with Lua scripts
BSD 3-Clause "New" or "Revised" License
293 stars 43 forks source link

fix: reduce peak memory usage #308

Closed hchunhui closed 5 months ago

hchunhui commented 5 months ago

fix #307

hchunhui commented 5 months ago

@iDvel 能帮忙测试一下吗?原问题的是 lua 不能正常感知到 C++ 对象对内存的占用,垃圾回收进行过慢。但我并不熟悉 lua gc,不太确定是否奏效。

shewer commented 5 months ago

rime.lua 初始化後狀態 3xxK , register 341

count = 0; for k,v in next , debug.getregistry() do count = count +1 ;print(count, k,v ) end
for i=1,100 do
  local str = i .. ":"
  for j=1,5 do
    str = str .. " " .. ("%.f"):format(collectgarbage('count'))
  end
  print(str)
end
os.exit()

http://fars.ee/x-Id

iDvel commented 5 months ago

2024-02-03-002421

我在小狼毫上换了 dll 后,内存就超稳了。

请问怎么在鼠须管上更新呢,这样复制过去后,librime 版本是新的了,但是没有 Lua 功能: 2024-02-03-002424

mirtlecn commented 5 months ago

这个 PR 是否能修复 OpenCC 函数内存问题,也与 lua 不能正常感知到 C++ 对象对内存占用有关。

https://github.com/hchunhui/librime-lua/issues/206

shewer commented 5 months ago

这个 PR 是否能修复 OpenCC 函数内存问题,也与 lua 不能正常感知到 C++ 对象对内存占用有关。

206

測試有效果 , 畢竟 每次刷新候選 都會GC一遍

iDvel commented 5 months ago

在彻底解决前,自己加个 lua_translator@force_gc 是不是也行,试了两天,输入不卡顿,内存也稳。

function force_gc()
    -- collectgarbage()
    collectgarbage("step")
end
shewer commented 5 months ago

放在 notifier 也可以 update_notifier 每次 compose() commit_notifier 每次 commit()