Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added TrackObjects panel

  • Loading branch information...
commit 4d9fd294a8b1642f101ce7befc87d8cc59ffd6fc 1 parent 2160d04
@miyagawa authored
Showing with 66 additions and 0 deletions.
  1. +66 −0 lib/Plack/Middleware/Debug/TrackObjects.pm
View
66 lib/Plack/Middleware/Debug/TrackObjects.pm
@@ -0,0 +1,66 @@
+package Plack::Middleware::Debug::TrackObjects;
+use strict;
+use parent qw(Plack::Middleware::Debug::Base);
+
+sub run {
+ my($self, $env, $panel) = @_;
+
+ unless ($INC{"Devel/TrackObjects.pm"}) {
+ return $panel->disable;
+ }
+
+ return sub {
+ my $res = shift;
+
+ my $track = Devel::TrackObjects->show_tracked_detailed;
+ my @content;
+
+ foreach (@$track){
+ if (length($_->[0]) > 100){
+ $_->[0] = substr($_->[0],0,100);
+ }
+ push @content, $_->[0], $_->[1].' - '.$_->[2];
+ }
+
+ $panel->nav_subtitle('Number:'.scalar(@content)/2);
+
+ $panel->content(
+ $self->render_list_pairs([@content])
+ );
+ };
+
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Plack::Middleware::Debug::TrackObjects - Track Objects panel
+
+=head1 SYNOPSIS
+
+ enable "Debug";
+ enable "Debug::TrackObjects";
+
+And when you load the application with plackup or other launcher:
+
+ # track everything
+ plackup -MDevel::TrackObjects=/^/ myapp.psgi
+
+You can specify the namespace with a regular expression. See
+L<Devel::TrackObjects> for details.
+
+=head1 DESCRIPTION
+
+This debug panel captures objects created in a request cycle by using
+L<Devel::TrackObjects>. You can run your applications multiple times
+(i.e. refreshing the page) to see if the count of tracked objects
+increases, in which case there are leaked objects.
+
+=head1 SEE ALSO
+
+L<Plack::Middleware::Debug> L<Devel::TrackObjects>
+
+=cut
Please sign in to comment.
Something went wrong with that request. Please try again.