I've compiled small C++ application for school project on my virtual ubuntu 11.04. However when I attempt to run it over some larger data set after ~20 sec the program is killed by OS.

Killed (SIGKILL)

I need to find out why and remove the problem. Could it be that I've not enough memory to run the program? Note: I need to find data set large enough to make it run for several minutes.

  • Strange, when you request resources like memory or IO operation, the OS will say "OK" or "not OK", but killing the process seems a little drastic. What could have happened is that you were killed because you performed an invalid operation (accessing memory you can't access). Do you have BUS ERROR/Segmentation Fault errors? Run your program within gdb (gdb ./program and hit 'r [arg1] [arg2] to run it), provide us with the output. – Aki Feb 8 '12 at 18:26
  • How large is large? Also, what ulimits is it running under? Type ulimit on the same console you're running your program from to see if the environment is severely limiting some resource you might need (e.g. memory, CPU time, etc). – Alexios Feb 8 '12 at 18:32
  • 1
    Can you share the code? Or at least the part of the code where it happens (you can build it with debug information and run it under some debugger like gdb — when it gets killed, you should be able to get a backtrace (although I'm not sure about how gdb handles SIGKILL, I know SIGSEGV can be trapped by gdb, now SIGKILL I don't know.) – njsg Feb 8 '12 at 18:38
  • 3
    Also check dmesg, might be some info there. – Mat Feb 8 '12 at 18:44
  • 2
    @aki - Often resources are allocated on the assumption that they will be available when required. Many OSes overallocate on this assumption. – Chris Down Feb 8 '12 at 19:39

It's probably killed by kernel's oom killer. dmesg should contain information about it. Sorry, but you may need to redesign your algorithm.

  • Would the OOM killer kill this application? Isn't it designed to select a program with a half-random algorithm and kill it? ahh.. I really despise the OOM killer, I understand why it's needed though... Wish one could build a linux kernel with a -DLOGICAL_BEHAVIOR flag :). – Aki Feb 8 '12 at 21:47
  • It tries to kill most memory-hungry application. In some cases (due to memory sharing) it can kill wrong application, but most of the time it does the right thing. – rvs Feb 9 '12 at 6:10
  • Oh it evolved well since the time it used to kill sshd. – Aki Feb 9 '12 at 6:12
  • You can disable the OOM killer if you really like to. But then you are no longer able to over-allocate memory. – Nils Feb 9 '12 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.