As my hosting needs grow, I am continually surprised at how well Amazon EC2 t1.micro instances meet those needs as long as I’m serving up rather static or barely dynamic content. However, they sometimes fall short when intense computational, CPU, or network bursts surface.
The Problem
While compiling a daemon from C++ source in my t1.micro, it stopped with an unusual error:
g++: internal compiler error: Killed (program cc1plus)
The last few lines of output from dmesg showed the cause:
[26601705] Out of memory: Kill process 30909 (cc1plus) [26601705] Killed process 30909 (cc1plus) total-vm:592952kB, anon-rss:548596kB, file-rss:0kB
The t1.micro instance simply ran out of memory needed for the compile.
The Solution
Create a 1GB swap file that enables some of your disk space to be used for memory:
sudo dd if=/dev/zero of=/swapfile bs=64M count=16 sudo mkswap /swapfile sudo swapon /swapfile
The process on the tiny instance was as achingly slow as expected, but after an hour of maxing out the CPU at 100% my daemon finishing compiling without any additional errors. Any glitches found thereafter were the fault of my own programming, and not the compiler.
Recent Comments