Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why mongodb on 32-bit machine has limitation of datasize to 2GB , not 4GB?

Tags:

mongodb

as here mention, mongodb has limitation of datasize to 2GB in 32-bit machine with one single mongod instance. But I wonder 32-bit machine has 4GB addressable space in theory, and mongod can use this 4GB instead of 2GB for virtual memory usage. So why the answer is 2GB, not 4GB?

like image 513
jianpx Avatar asked Dec 26 '22 08:12

jianpx


2 Answers

4Gb of addressable space is not the same as the memory space available for memory-mapped files opened by user applications. Some of the addressable space is reserved for the O/S kernel and memory-mapped devices such as video cards.

For example, 32-bit Windows limits user mode (and thus memory-mapped files) to ~2Gb RAM and total system RAM to ~3.5Gb.

For more reading, see:

  • Coding Horror: Dude, Where's My 4 Gigabytes of RAM?
  • MSDN: Managing Memory-Mapped Files
  • MSDN: Memory-Mapped Files

The majority of modern desktop and server environments starting moving to 64-bit almost a decade ago (see 64-bit operating system timeline on Wikipedia) so this isn't a limit that practically affects deployment.

You would only want to use 32-bit MongoDB in a development environment with limited data.

like image 135
Stennie Avatar answered Jan 19 '23 00:01

Stennie


32-bit MongoDB processes are limited to about 2 gb of data. This has come as a surprise to a lot of people who are used to not having to worry about that. The reason for this is that the MongoDB storage engine uses memory-mapped files for performance.

By not supporting more than 2gb on 32-bit, we’ve been able to keep our code much simpler and cleaner. This greatly reduces the number of bugs, and reduces the time that we need to release a 1.0 product.

http://blog.mongodb.org/post/137788967/32-bit-limitations

like image 27
Matt Ball Avatar answered Jan 18 '23 22:01

Matt Ball