2

美好的一天,我是 tarantool 的新手,我对 tarantool 内的客户端应用程序的内存限制有疑问,我有 3 亿个项目的内存数据库和选择其中一部分的 lua 应用程序,选择后我将结果包装到“”更简单的代码交互。例如:

Foo = {}
Foo.__index = Foo

function Foo.create(rawData)
    local self = setmetatable({}, Foo)

    self.PrimaryId = rawData[1]
    self.BarId     = rawData[2]

    local fields = rawData[3]
    self.Name    = fields[1]
    self.Date    = fields[2]

    return self
end

和用法:

local data = box.space.Foo.index.barId:select({barId})
local ctor = Foo.create
local foo = {}

for i = 1, #data do
    table.insert(foo, ctor(data[i]))
end

在大多数情况下第一次运行时它运行成功,但第二次它以 100% 的概率失败并显示消息(tarantool 消息):

PANIC: unprotected error in call to Lua API (not enough memory)

我了解,内存使用存在问题(未释放的内存),但我对限制有疑问 - lua 应用程序是否有一些限制?因为我在监视器中看到内存消耗并注意到有足够的可用内存并且在应用程序开始使用超过 1.2 Gb 后出现故障

4

1 回答 1

3

Tarantool 使用 luajit,这意味着限制来自 luajit [1]。

此外,luajit(如 lua)的垃圾收集器[2] 存在问题,有时您必须手动调用它[3] 否则您会出现“OOM 恐慌”。

[1] 链接:

[2] http://wiki.luajit.org/New-Garbage-Collector

[3] http://luatut.com/collectgarbage.html

于 2018-05-25T07:53:56.783 回答