MongoDB eating a lot of memory!

184 views
Skip to first unread message

simon66

unread,
Nov 29, 2011, 9:27:00 PM11/29/11
to mongod...@googlegroups.com
So I just switched over to MongoDB from MySQL, and so far is great! Really fast! But it looks like that I'll be switching over to MySQL again.

There is something wrong with my mongod program. It's eating about 8GB of ram and I don't know what to do.

Here is a picture


if you notice the mongod window in the bottom right.

Any help?

Nat

unread,
Nov 29, 2011, 11:25:19 PM11/29/11
to mongod...@googlegroups.com
It's normal since MongoDB uses memory mapped file to access database files. OS will manage its memory usage. If you have plenty of memory and you access most of the data in your data files, it's possible that mongodb will consume memory as much as your database size.

Varela

unread,
Nov 30, 2011, 5:28:21 AM11/30/11
to mongod...@googlegroups.com
MongoDB is document based and doesn't have strict schema like MySQL, so it should keep schema in each document rather than have one schema definition per table. That's why size of you database should be large than same MySQL database, larger database size should use more memory.

Sam Millman

unread,
Nov 30, 2011, 5:37:11 AM11/30/11
to mongod...@googlegroups.com
"keep schema in each document rather than have one schema definition per table"

Mongodb does not house schema definition at all.

As Nat said the reason why MongoDB uses a lot of memory is because it uses memory mapped files.

On 30 November 2011 10:28, Varela <zmiev...@gmail.com> wrote:
MongoDB is document based and doesn't have strict schema like MySQL, so it should keep schema in each document rather than have one schema definition per table. That's why size of you database should be large than same MySQL database, larger database size should use more memory.

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/VHsHUgR9_ZMJ.

To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Varela

unread,
Nov 30, 2011, 6:17:31 AM11/30/11
to mongod...@googlegroups.com
By schema I mean name and type of the fields

Sam Millman

unread,
Nov 30, 2011, 7:50:30 AM11/30/11
to mongod...@googlegroups.com
I am not sure what you mean, maybe you can elaborate?

If you mean that a field name and type (if there is one, 90% of all fields don't have a stored type) will consume some memory then yes that is correct but that is not the reason why memory is eaten by mongo, this is more to do with the smallest allocation possible in comparison with the size and length of your field names/values.

MongoDB in general uses more memory due to memory mapped files, also judging by that screen shot I would say he has not got a lot of BSON types stored and also his field names are relatively small.


On 30 November 2011 11:17, Varela <zmiev...@gmail.com> wrote:
By schema I mean name and type of the fields

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/3mduEb6i6DgJ.

Varela

unread,
Nov 30, 2011, 8:04:21 AM11/30/11
to mongod...@googlegroups.com
Completelly agree with you - that memory mapped files is the reason. But I have a suspiction that MongoDB requires at least in 2 times more disc space for the same data than relational databases. Since MongoDB put to memory projection of DB files there can be IO performance problems with replacing memory pages while MySQL will be able just keep all required data in memory. I'm going to do research on this.

Sam Millman

unread,
Nov 30, 2011, 8:11:08 AM11/30/11
to mongod...@googlegroups.com
Again I'm not sure what you mean by problems.

I mean hot sets are kept in memory using the LRU algorithm, the files are just memory mapped to pages.

On 30 November 2011 13:04, Varela <zmiev...@gmail.com> wrote:
Completelly agree with you - that memory mapped files is the reason. But I have a suspiction that MongoDB requires at least in 2 times more disc space for the same data than relational databases. Since MongoDB put to memory projection of DB files there can be IO performance problems with replacing memory pages while MySQL will be able just keep all required data in memory. I'm going to do research on this.

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/KemhE8Hx4sIJ.

Sam Millman

unread,
Nov 30, 2011, 8:21:51 AM11/30/11
to mongod...@googlegroups.com
There can be IO problems with mapping yes, but I am tbh I am not sure what you mean by "problems" so I can't really give a answer.

Scott Hernandez

unread,
Nov 30, 2011, 8:31:37 AM11/30/11
to mongod...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages