"Cannot allocate memory" Displayed When Compiling RocksDB
Symptom
The error message "Cannot allocate memory" is displayed when compiling RocksDB.
Key Process and Cause Analysis
When make -j is executed for RocksDB compilation, all CPU cores are used. As a result, the memory becomes insufficient.
Conclusion and Solution
- Delete all files and subdirectories in the current directory.
rm -rf *
- Use the CMake tool to compile and install RocksDB and specify the installation path, for example, /usr/local/rocksdb.
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/rocksdb -DWITH_SNAPPY=1 -DWITH_ZLIB=1 -DWITH_LZ4=1 -DWITH_ZSTD=1 -DWITH_BZ2=1 ..
- Check the number of CPU cores.
lscpu
- Run the compile command again. In the following command, the number of CPU cores to be used is reduced.
make -j 8
Parent topic: Troubleshooting