【发布时间】:2016-07-26 12:38:10
【问题描述】:
当我执行查询时
Mymodel.all.each do |model|
# ..do something
end
它使用分配的内存,并且使用的内存量一直在增加,并且它崩溃了。我发现要修复它,我需要禁用 identity_map 但是当我添加到我的 mongoid.yml 文件 identity_map_enabled: false 时出现错误
Invalid configuration option: identity_map_enabled.
Summary:
A invalid configuration option was provided in your mongoid.yml, or a typo is potentially present. The valid configuration options are: :include_root_in_json, :include_type_for_serialization, :preload_models, :raise_not_found_error, :scope_overwrite_exception, :duplicate_fields_exception, :use_activesupport_time_zone, :use_utc.
Resolution:
Remove the invalid option or fix the typo. If you were expecting the option to be there, please consult the following page with repect to Mongoid's configuration:
I am using Rails 4 and Mongoid 4, Mymodel.all.count => 3202400
我该如何解决它,或者也许有人知道其他方法来减少执行查询 .all.each .. 期间使用的内存量? 非常感谢你的帮助!!!!
【问题讨论】:
标签: ruby-on-rails mongodb memory-leaks mongoid