… | |
… | |
9 | $^O eq "linux" or die "only linux supported right now.\n"; |
9 | $^O eq "linux" or die "only linux supported right now.\n"; |
10 | |
10 | |
11 | Event->timer ( |
11 | Event->timer ( |
12 | reentrant => 0, |
12 | reentrant => 0, |
13 | data => cf::WF_AUTOCANCEL, |
13 | data => cf::WF_AUTOCANCEL, |
14 | interval => 1, |
14 | interval => 10, |
15 | after => 1, |
15 | after => 10, |
16 | cb => sub { |
16 | cb => sub { |
17 | open my $fh, "</proc/self/stat" |
17 | open my $fh, "</proc/self/stat" |
18 | or return; |
18 | or return; |
19 | |
19 | |
20 | sysread $fh, my $stat, 4096; # only a single line |
20 | sysread $fh, my $stat, 4096; # only a single line |
21 | my $vmsize = (split / /, $stat)[22]; |
21 | my $vmsize = (split / /, $stat)[22]; |
22 | |
22 | |
23 | cf::cleanup "memory usage growing high, server would run out of memory soon", 0 if $vmsize >= $MAX_VMSIZE; |
23 | cf::cleanup "memory usage growing high, server would run out of memory soon", 0 |
|
|
24 | if $vmsize >= $MAX_VMSIZE; |
24 | }, |
25 | }, |
25 | ); |
26 | ); |