home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / Leak.pm < prev    next >
Encoding:
Perl POD Document  |  2000-01-22  |  1.5 KB  |  62 lines

  1. package Devel::Leak;    
  2. use 5.005;
  3. use vars qw($VERSION);
  4. require DynaLoader;
  5. use base qw(DynaLoader);
  6. $VERSION = '0.02';
  7.  
  8. bootstrap Devel::Leak;
  9.  
  10. 1;
  11. __END__
  12.  
  13. =head1 NAME
  14.  
  15. Devel::Leak - Utility for looking for perl objects that are not reclaimed.
  16.  
  17. =head1 SYNOPSIS
  18.  
  19.   use Devel::Leak;
  20.   ... setup code 
  21.  
  22.   my $count = Devel::Leak::NoteSV($handle);
  23.  
  24.   ... code that may leak 
  25.  
  26.   Devel::Leak::CheckSV($handle); 
  27.  
  28. =head1 DESCRIPTION 
  29.  
  30. Devel::Leak has two functions C<NoteSV> and C<CheckSV>. 
  31.  
  32. C<NoteSV> walks the perl internal table of allocated SVs (scalar values) - (which
  33. actually  contains arrays and hashes too), and records their addresses in a
  34. table. It returns a count of these "things", and stores a pointer to the 
  35. table (which is obtained from the heap using malloc()) in its argument.
  36.  
  37. C<CheckSV> is passed argument which holds a pointer to a table created by 
  38. C<NoteSV>. It re-walks the perl-internals and calls sv_dump() for any "things"
  39. which did not exist when C<NoteSV> was called. It returns a count of the number 
  40. of "things" now allocated. 
  41.  
  42. =head1 CAVEATS
  43.  
  44. Note that you need a perl built with -DDEBUGGING for
  45. sv_dump() to print anything, but counts are valid in any perl.
  46.  
  47. If new "things" I<have> been created, C<CheckSV> may (also) report additional
  48. "things" which are allocated by the sv_dump() code.
  49.  
  50. =head1 HISTORY
  51.  
  52. This little utility module was part of Tk until the variable renaming
  53. in perl5.005 made it clear that Tk had no business knowing this much
  54. about the perl internals.
  55.  
  56. =head1 AUTHOR
  57.  
  58. Nick Ing-Simmons <nick@ni-s.u-net.com>
  59.  
  60. =cut
  61.  
  62.