From c6dbc8eb84082748c2e9eb619c0e58ea1695de4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= <mpg@elzevir.fr>
Date: Mon, 1 Dec 2014 14:05:45 +0100
Subject: [PATCH] Output stack+heap usage with massif

---
 scripts/massif_max.pl | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/scripts/massif_max.pl b/scripts/massif_max.pl
index df30f0f8e..d1ce4ca7d 100755
--- a/scripts/massif_max.pl
+++ b/scripts/massif_max.pl
@@ -15,7 +15,7 @@ open my $fh, '<', $ARGV[0] or die;
 { local $/ = 'snapshot='; @snaps = <$fh>; }
 close $fh or die;
 
-my $max = 0;
+my ($max, $max_heap, $max_he, $max_stack) = (0, 0, 0, 0);
 for (@snaps)
 {
     my ($heap, $heap_extra, $stack) = m{
@@ -25,7 +25,9 @@ for (@snaps)
     }xm;
     next unless defined $heap;
     my $total = $heap + $heap_extra + $stack;
-    $max = $total if $total > $max;
+    if( $total > $max ) {
+        ($max, $max_heap, $max_he, $max_stack) = ($total, $heap, $heap_extra, $stack);
+    }
 }
 
-printf "$max\n";
+printf "$max (heap $max_heap+$max_he, stack $max_stack)\n";