首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >搜索记忆泄漏

搜索记忆泄漏
EN

Stack Overflow用户
提问于 2022-03-03 09:23:05
回答 1查看 2.2K关注 0票数 0

为应用程序运行rake searchkick:reindex CLASS=Product会导致Rake进程泄漏内存;大约15-20分钟后,就足以冻结一个内存为16 of的Debian系统。有3800条“产品”记录。

我设法用Rake任务中的以下代码解决了这个问题:

代码语言:javascript
复制
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

这也要快一点。

有人能提出调查这个记忆泄漏的方法吗?在考虑开一张票之前,最好更详细地这样做。

EN

回答 1

Stack Overflow用户

发布于 2022-04-28 15:32:04

这会导致生成索引时出现问题:Text fields are not optimised for operations that require per-document field data

可以通过在上面的代码中添加以下内容来解决这个问题:

代码语言:javascript
复制
Product.reindex(import: false)
# Rest of code goes here...
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71334743

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档