[Jifty-commit] r4672 - in jifty/trunk: lib/Jifty/Plugin lib/Jifty/Plugin/LeakTracker

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Dec 13 04:34:35 EST 2007


Author: sartak
Date: Thu Dec 13 04:34:35 2007
New Revision: 4672

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/META.yml
   jifty/trunk/Makefile.PL
   jifty/trunk/lib/Jifty/Plugin/LeakTracker.pm
   jifty/trunk/lib/Jifty/Plugin/LeakTracker/View.pm

Log:
 r49016 at onn:  sartak | 2007-12-13 04:33:49 -0500
 LeakTracker: log how much memory we're using at each request if Proc::ProcessTable is installed


Modified: jifty/trunk/META.yml
==============================================================================
--- jifty/trunk/META.yml	(original)
+++ jifty/trunk/META.yml	Thu Dec 13 04:34:35 2007
@@ -50,6 +50,7 @@
   Net::Server::Fork: 0
   Net::Server::PreFork: 0
   PAR::Dist::FromCPAN: 0
+  Proc::ProcessTable: 0
   Test::Base: 0.44
   Test::HTML::Lint: 0
   Test::HTTP::Server::Simple: 0.02

Modified: jifty/trunk/Makefile.PL
==============================================================================
--- jifty/trunk/Makefile.PL	(original)
+++ jifty/trunk/Makefile.PL	Thu Dec 13 04:34:35 2007
@@ -166,6 +166,7 @@
         recommends('Devel::Events::Handler::ObjectTracker'),
         recommends('Devel::Events::Generator::Objects'),
         recommends('Devel::Size'),
+        recommends('Proc::ProcessTable'),
     ],
     'OAuth Plugin' => [
         -default => 0,

Modified: jifty/trunk/lib/Jifty/Plugin/LeakTracker.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/LeakTracker.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/LeakTracker.pm	Thu Dec 13 04:34:35 2007
@@ -73,6 +73,20 @@
     # XXX: Devel::Size seems to segfault Jifty at END time
     my $size = total_size([ @leaks ]) - $empty_array;
 
+    my $total = '?';
+
+    # report total memory, if able
+    eval {
+        require Proc::ProcessTable;
+        my $proc = Proc::ProcessTable->new;
+        for (@{ $proc->table }) {
+            next unless $_->pid == $$;
+            $total = $_->size;
+            last;
+        }
+    };
+    Jifty->log->warn($@) if $@;
+
     push @requests, {
         id => 1 + @requests,
         url => $cgi->url(-absolute=>1,-path_info=>1),
@@ -80,6 +94,7 @@
         objects => Dumper($leaked),
         time => scalar gmtime,
         leaks => \@leaks,
+        total => $total,
     };
 
     $self->generator(undef);

Modified: jifty/trunk/lib/Jifty/Plugin/LeakTracker/View.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/LeakTracker/View.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/LeakTracker/View.pm	Thu Dec 13 04:34:35 2007
@@ -34,6 +34,7 @@
             th { "ID" }
             th { "Leaks" }
             th { "Bytes leaked" }
+            th { "Total size" }
             th { "Time" }
             th { "URL" }
         };
@@ -49,6 +50,7 @@
 
                 cell { scalar @{$_->{leaks}} }
                 cell { $_->{size} }
+                cell { $_->{total} }
                 cell { $_->{time} }
                 cell { $_->{url} }
             };
@@ -63,8 +65,9 @@
     ul {
         li { "URL: $leak->{url}" }
         li { "Time: $leak->{time}" }
+        li { "Total memory used: $leak->{total} bytes" }
         li { "Objects leaked: " . scalar(@{$leak->{leaks}}) }
-        li { "Total memory leaked: $leak->{size} bytes" }
+        li { "Memory leaked: $leak->{size} bytes" }
     }
     p { a { attr { href => "/__jifty/admin/leaks" } "Table of Contents" } }
     hr {}


More information about the Jifty-commit mailing list