当我在所有的时间,并在正在执行的查询Mongoid identity_map和内存使用情况,内存泄漏
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 ..? 非常感谢您的帮助!
嗨!谢谢您的回答。 “我试过Mymodel。每个人都做'没有'全部'它使用相同的大量内存和最后的粉碎。你介意给我演示如何在Mongoid中通过mapReduce实现'Mymodel.each do'请!!! – 2014-12-05 08:50:57
做'Mymodel.each'也会加载它们全部。正如我所说的,在使用mapReduce或聚合框架之前,您需要将您的“做某件事”步骤转换为MongoDB将理解的形式。 – 2014-12-05 18:10:42