What is the best way to prevent out of memory (OOM) freezes on Linux? -


Is there any way to work with OOM Killer and to prevent Linux from freezing? I am running Java and C # applications, where any of the allocated memory is usually used, and (if I understand them right) are freeing the overcomment machine. Now, as a temporary solution, I said, /etc/sysctl.conf in

  vm.overcommit_memory = 2 vm.overcommit_ratio = 10  

.

Let anyone know why the current OOM weapon can not work properly in a guaranteed manner, whenever the kernel moves out of "real" memory kills the processes.

Edit - Many answers are on the lines of Michael. "If you are facing OOM killer related problems, you probably have to run away from memory It has to be corrected ". I do not think this is the right solution, there will always be worm-like apps, and I would like to adjust the kernel so that my whole system is not free. Given my current technical understanding, it does not seem that it should be impossible.

Below is actually the original Perl script I wrote, with a little tweaking it can be useful to you The path must be changed near the path of any process using Java or C #. You can also use the command to start the command again. Certainly to avoid perl memusage.pl typing manually, you can put it in your crontab file to run automatically. You can also use Perl memusage.pl> log.txt to save your output to the log file. Sorry, if it does not really help, but I was bored of drinking a cup of coffee: - D Cheers

  #! / Usr / bin / perl -w # Checks the available memory usage and calculates the size in MB # If the free storage is specified below your minimum level, then # script attempts to turn off troubled processes # which you specify If it does not happen, then it will give a 9-kelly signal. # # Uses external commands (cat and pidoff) # # Cheers, our $ memmin = 50 is worthwhile; Our @ promo = qw (/ usr / bin / firefox / usr / local / sbin / apache2); Kill the sub {vars qw (@procs); My @ Pids = (); Foreach $ proc (@procs) {my $ filename = substr ($ proc, rindex ($ proc, "/") + 1, length ($ proc) -rindex ($ proc, "/") - 1); My $ pid = `pidof $ filename`; Cutting ($ PID); My @ pd = partition (/ /, $ pid); Push @ pad, $ pid [0]; } Foreach $ pid (@pids) {# attempt to kill normal system first # ("kill-15". $ Pid); Print "Murder" $ Pid "\ N"; Sleeping 1; If (-e "/ proc / $ pid") {print $ pid. "Still alive! One-9 hits ... \ n"; System ("kill-9" + $ pid); Print "completed \ n"; } And {print "looks" $ Pid "dead" \ n "; }} Print "finished the memory-hogging processes! \ N"; Exit (0); } Use sub-test {vars qw ($ memmin); Mine ($ free) = $ _ [0]; If ($ free> $ memmin) {Print "Memory Usage is OK \ n"; Exit (0); } And {killProcs (); }} Sub Head {My $ meminfo = `cat / proc / meminfo`; ($ Meminfo) cut; My @meminfo = split (/ \ n /, $ meminfo); My line $ foreach (@meminfo) {if ($ line = ~ /^MemFree:\s+(.+)\skB$/) {my $ free = ($ 1/1024); & Amp; CheckMem ($ free); }     } }  Main();  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -