Reputation: 67
When executing my program inside an Amazon EC2 instance (t2.small, Oregon, Ubuntu 16.04), I get the error
ElectricFence Exiting: mprotect() failed: Cannot allocate memory
The steps I follow after launching the instance are:
Install build-essentials, pip and cmake
sudo apt-get update && sudo apt-get install build-essential python-pip cmake
Install the conan package manager
pip install conan
Clone the repository
git clone https://github.com/oyarsa/faptp.git
Cd into repo, create build folder, install dependencies and run cmake
mkdir build && cd build
conan install .. -s compiler=gcc -s compiler.libcxx=libstdc++11 --build=missing
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
cmake --build .
After compilation, I go back to the root directory and try to run the program
cd .. && ./build/bin/faptp
In doing this, the program executes for a while and then exits with this output:
SA-ILS
ElectricFence Exiting: mprotect() failed: Cannot allocate memory
The SA-ILS is output from my program. The error from ElectricFence is the problem. I've never heard of that before, and this is the first time I run this program inside EC2, so I assume it has something to do with it.
The source code is at https://github.com/oyarsa/faptp, if it helps.
Upvotes: 0
Views: 365
Reputation: 37460
Are you sure the error isn't because, well, it can't allocate any more memory?
A t2.small instance has 2GB of RAM, and by default swap is not enabled. So if you need more than that, you're going to see that error.
There is an easy way to determine if it's a problem with the OS, or if you're actually running out of memory: stop the instance, change it to a larger instance type, and restart it. A t2.large has 8GB of RAM, and to spin one up and test it will cost you $0.094, assuming you don't leave it running for more than an error. If that works, then try a t2.medium, which will cost $0.047 to try. (Or, if wasting a dime is too expensive, you can try starting with the t2.medium)
Upvotes: 1