Skip to content

Commit

Permalink
Report maximum memory at termination
Browse files Browse the repository at this point in the history
In addition to the current memory (which is, in many cases, useless),
report maximum memory stamp during the execution
  • Loading branch information
Pavel Shved authored and pshved committed Sep 1, 2011
1 parent 398c873 commit d2added
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion timeout
Expand Up @@ -109,6 +109,8 @@ my $timeinfo = { total => 0, finished => 0, current => {} };
# For this -- update_memory
my $meminfo = 0;
my $fulltime = 0;
# We store the "maximum" used memory (the process may free it and we won't get the proper timestamp at the end).
my $maxmem = -1;

# Default ticklimit - limit of number of timeout script wakeups (ticks) before we decide that the controlling processes are hang up (if they haven't done any useful work). We use ticks instead of real time seconds because the whole stack may be paused with SIGSTOP, and should not die in this case.
#
Expand All @@ -134,6 +136,7 @@ while ($status eq 'wait'){
# According to signal(7), wait is a safe function, so we can call anything we want here.
$timeinfo = update_time($blackbox_pid,$timeinfo);
$meminfo = update_memory($blackbox_pid,$meminfo);
$maxmem = $meminfo if $meminfo > $maxmem;
update_info_by_ucmd($blackbox_pid,$uinfo);
die "Assume waitpid return 0\n";
};
Expand Down Expand Up @@ -404,7 +407,7 @@ sub print_uinfo
my $reason = shift;
# Print generic information to STDERR
my $ticks = $timeinfo->{ticks_stale} || 0;
printf STDERR "${id_str}%s CPU %.2f MEM %d STALE %d\n", $reason, $timeinfo->{total}, $meminfo, ceil($ticks/$frequency);
printf STDERR "${id_str}%s CPU %.2f MEM %d MAXMEM %d STALE %d\n", $reason, $timeinfo->{total}, $meminfo, $maxmem, ceil($ticks/$frequency);

if (defined $output){
open(FIL,">>", $output) or die "Can't open output file: $!\n";
Expand Down

0 comments on commit d2added

Please sign in to comment.