Devel::GC::Helper - Perl extension for finding unused variables


  use Devel::GC::Helper;
  my $leaks = Devel::GC::Helper::sweep;
  foreach my $leak (@$leaks) {
      print "Leaked $leak";


This module walks the entire perl space, from main:: and notes what it has found, then it walks all SVs that are active and tells you which ones are potential leaks.


None by default.


Returns an arrayref of references to all containers that it didn't find in the mark phase.


This module can be used together with Devel::Cycle to find where there is a leak.

You can trac the repository at


Will only work in threaded perl correctly, it won't find regular expressions in non threaded perl because it is not walking the op tree. Nor will it find constants.

Leaked regular expressions won't be reported, because I can't figure out how to tell if they are active or not, I also haven't looked closely at it since I don't have much of a problem with leaking regexen.

There are three variables, tvo magic elements and one array that I have not tracked down where they come from that are always reported as leaked. I suspect they are from within DynaLoader/Exporter.


Artur Bergman, <>


Copyright (C) 2006 by Artur Bergman

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.