Searchkick 内存泄漏
对应用程序运行 rake searchkick:reindex CLASS=Product
会导致 Rake 进程泄漏内存;大约 15-20 分钟后,它就足以冻结具有 16GB RAM 的 Debian 系统。有 ~3800 个“产品”记录。
我设法在 Rake 任务中使用以下代码解决了这个问题:
connection = ActiveRecord::Base.connection
res = connection.execute('select max(id) from products')
id = res.getvalue(0,0)
1.upto(id) do |i|
p = Product.find_by_id(i)
next unless p
p.reindex
end
这也更快一些。
任何人都可以建议一种方法来调查此内存泄漏吗?在考虑开票之前更详细地了解一下会很有用。
Running rake searchkick:reindex CLASS=Product
for an application causes the Rake process to leak memory; after about 15-20 minutes it's bad enough to freeze a Debian system with 16GB of RAM. There are ~3800 "Product" records.
I managed to work around this problem with the following code in a Rake task:
connection = ActiveRecord::Base.connection
res = connection.execute('select max(id) from products')
id = res.getvalue(0,0)
1.upto(id) do |i|
p = Product.find_by_id(i)
next unless p
p.reindex
end
This is also a little quicker.
Can anyone suggest a means to investigate this memory leak? It would be useful to do so in more detail before considering opening a ticket.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这会导致生成索引时出现问题: 文本字段未针对需要每个文档字段数据的操作进行优化
该问题可以通过在上面的代码中添加以下内容来解决:
This causes a problem with generating indexes: Text fields are not optimised for operations that require per-document field data
That problem can be fixed by adding the following to the code above: