4 * Copyright (C) 2009 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
16 int option_oom_kb
= 800000; // 800 megs
18 static long get_mem_used()
20 static char filename
[64];
21 static char buf
[4096];
26 snprintf(filename
, 63, "/proc/%d/status", getpid());
29 fd
= open(filename
, O_RDONLY
);
32 if (read(fd
, buf
, 4096) < 0) {
39 while ((line
= strchr(line
, 'V')) > 0) {
40 if (!strncmp(line
, "VmSize:", 7))
41 return atol(line
+ 8);
49 if (get_mem_used() > option_oom_kb
)