| 1 |
.. -*- rst -*- |
| 2 |
|
| 3 |
How to avoid mmap Cannot allocate memory error |
| 4 |
============================================== |
| 5 |
|
| 6 |
Example |
| 7 |
------- |
| 8 |
|
| 9 |
There is a case following mmap error in log file: |
| 10 |
|
| 11 |
2013-06-04 08:19:34.835218|A|4e86e700|mmap(4194304,551,432017408)=Cannot allocate memory <13036498944> |
| 12 |
|
| 13 |
Note that <13036498944> means total size of mmap (almost 12GB) in this case. |
| 14 |
|
| 15 |
Solution |
| 16 |
-------- |
| 17 |
|
| 18 |
So you need to confirm following point of views. |
| 19 |
|
| 20 |
* Are there enough free memory? |
| 21 |
* Are maximum number of mappings exceeded? |
| 22 |
|
| 23 |
To check there are enough free memory, you can use vmstat command. |
| 24 |
|
| 25 |
To check whether maximum number of mappings are exceeded, you can investigate the value of vm.max_map_count. |
| 26 |
|
| 27 |
If this issue is fixed by modifying the value of vm.max_map_count, it's exactly the reason. |
| 28 |
|
| 29 |
As groonga allocates memory chunks each 256KB, you can estimate the size of database you can handle by following formula: |
| 30 |
|
| 31 |
(database size) = vm.max_map_count * (memory chunks) |
| 32 |
|
| 33 |
If you want to handle over 16GB groonga database, you must specify at least 65536 as the value of vm.max_map_count: |
| 34 |
|
| 35 |
database size (16GB) = vm.max_map_count (65536) * memory chunks (256KB) |
| 36 |
|
| 37 |
You can modify vm.max_map_count temporary by sudo sysctl -w vm.max_map_count=65536. |
| 38 |
|
| 39 |
Then save the configuration value to ``/etc/sysctl.conf`` or ``/etc/sysctl.d/*.conf``. |
| 40 |
|
| 41 |
See :doc:`/reference/tuning` documentation about tuning related parameters. |
| 42 |
|
| 43 |
|