MongoDB out of memory

MongoDB is crashing. When I open the mongodb.log file, I get:

$ tail /var/log/mongodb/mongodb.log Sat Jan 25 03:06:56.153 [initandlisten] connection accepted from 127.0.0.1:58492 #63331 (263 connections now open) Sat Jan 25 03:07:02.694 out of memory, printing stack and exiting: 0xde05e1 0x6cf37e 0x12129fd 0xc490c3 0xc4404e 0xc44196 0xda4913 0xda53e4 0xe28e69 0x7f5cbaa19e9a 0x7f5cb9d2c3fd /usr/bin/mongod(_ZN5mongo15printStackTraceERSo+0x21) [0xde05e1] /usr/bin/mongod(_ZN5mongo14my_new_handlerEv+0x3e) [0x6cf37e] /usr/bin/mongod(_Znam+0x6d) [0x12129fd] /usr/bin/mongod(_ZNK5mongo3Top8cloneMapERNS_9StringMapINS0_14CollectionDataEEE+0x83) [0xc490c3] /usr/bin/mongod(_ZN5mongo9Snapshots12takeSnapshotEv+0x4e) [0xc4404e] /usr/bin/mongod(_ZN5mongo14SnapshotThread3runEv+0x66) [0xc44196] /usr/bin/mongod(_ZN5mongo13BackgroundJob7jobBodyEN5boost10shared_ptrINS0_9JobStatusEEE+0xc3) [0xda4913] /usr/bin/mongod(_ZN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf1IvN5mongo13BackgroundJobENS_10shared_ptrINS7_9JobStatusEEEEENS2_5list2INS2_5valueIPS7_EENSD_ISA_EEEEEEE3runEv+0x74) [0xda53e4] /usr/bin/mongod() [0xe28e69] /lib/x86_64-linux-gnu/libpthread.so.0(+0x7e9a) [0x7f5cbaa19e9a] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f5cb9d2c3fd] 

This question sounds similar: MongoDB: from memory But his problem was a complex problem. My memory settings are no longer limited.

Others had particular problems with .skip () or .limit (), given unreasonably large values, but this does not happen here.

Does anyone know what could be wrong?

+6
source share
1 answer

MongoDB docs recommend having enough swap space for MongoDB even though this is not a requirement: http://docs.mongodb.org/manual/administration/production-notes/#ProductionNotes-Swap

I am using Windows Azure hosting, and I found that their virtual servers do not have swap space by default:

 $ sudo swapon -s Filename Type Size Used Priority 

(Azure does not swap by default: Part 1 and Part 2 )

So, I found a guide on creating a paging file: https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04

And he solved my problem!

Notes:

  • The manual says that Ubuntu is 12.04, but the same steps worked for me on 13.10.
  • You should use the swap file at about half the size of your RAM, not the 512 MB used in the manual.

Hope this helps others solve this problem.

+7
source

All Articles