- my ($prefix) = $_[0] || "";
-
- if ($^O eq "linux") {
- if (!open(IN, "/proc/$$/status")) {
- &ERROR("cannot open '/proc/$$/status'.");
- return;
- }
-
- while (<IN>) {
- $memusage = $1 if (/^VmSize:\s+(\d+) kB/);
- }
- close IN;
-
- } elsif ($^O eq "netbsd") {
- $memusage = int( (stat "/proc/$$/mem")[7]/1024 );
-
- } elsif ($^O =~ /^(free|open)bsd$/) {
- my @info = split /\s+/, `/bin/ps -l -p $$`;
- $memusage = $info[20];
-
- } else {
- $memusage = "UNKNOWN";
- return;
- }
-
- if (defined $memusageOld and &IsParam("DEBUG")) {
- # it's always going to be increase.
- my $delta = $memusage - $memusageOld;
- my $str;
- if ($delta == 0) {
- return;
- } elsif ($delta > 500) {
- $str = "MEM:$prefix increased by $delta kB. (total: $memusage kB)";
- } elsif ($delta > 0) {
- $str = "MEM:$prefix increased by $delta kB";
- } else { # delta < 0.
- $delta = -$delta;
- # never knew RSS could decrease, probably Size can't?
- $str = "MEM:$prefix decreased by $delta kB.";
- }
-
- &status($str);
+ my ($prefix) = $_[0] || '';
+
+ if ( $^O eq 'linux' ) {
+ if ( !open( IN, "/proc/$$/status" ) ) {
+ &ERROR("cannot open '/proc/$$/status'.");
+ return;
+ }
+
+ while (<IN>) {
+ $memusage = $1 if (/^VmSize:\s+(\d+) kB/);
+ }
+ close IN;
+
+ }
+ elsif ( $^O eq 'netbsd' ) {
+ $memusage = int( ( stat "/proc/$$/mem" )[7] / 1024 );
+
+ }
+ elsif ( $^O =~ /^(free|open)bsd$/ ) {
+ my @info = split /\s+/, `/bin/ps -l -p $$`;
+ $memusage = $info[20];
+
+ }
+ else {
+ $memusage = 'UNKNOWN';
+ return;
+ }
+
+ if ( defined $memusageOld and &IsParam('DEBUG') ) {
+
+ # it's always going to be increase.
+ my $delta = $memusage - $memusageOld;
+ my $str;
+ if ( $delta == 0 ) {
+ return;
+ }
+ elsif ( $delta > 500 ) {
+ $str =
+ "MEM:$prefix increased by $delta KiB. (total: $memusage KiB)";
+ }
+ elsif ( $delta > 0 ) {
+ $str = "MEM:$prefix increased by $delta KiB";
+ }
+ else { # delta < 0.
+ $delta = -$delta;
+
+ # never knew RSS could decrease, probably Size can't?
+ $str = "MEM:$prefix decreased by $delta KiB.";
+ }
+
+ &status($str);