kr123 has asked for the wisdom of the Perl Monks concerning the following question:

I've got a large script whose memory usage slowly grows without bounds, so I must have some variable that is growing and it not leaving scope. However, I don't know which of many it could be.

Does anyone know how to dump the contents of ALL variables?

The tools I've seen for dumping variable contents all require specific variables to be supplied. If I could generate a list of all defined variables then this technique would be fruitful.

  • Comment on Dump of all defined variables for debugging

Replies are listed 'Best First'.
Re: Dump of all defined variables for debugging
by CountOrlok (Friar) on Feb 21, 2006 at 18:37 UTC
    Take a look at Devel::Symdump It can let you dump the contents of the symbol table.

    -imran

      Excellent.. Devel::Symdump gives me the list of variables. Unfortunately I'm having problems feeding that list into Data::Dumper so I can actually see the elements of all the variables.

      Know any tricks to this? If not my alternative may just be to do it the hard ware and manually input all of the defined variables.

        Here's some old code that might help: %main:: and my'd vars
        It walks through the %main:: symbol table and uses Data::Dumper to print out all arrays, hashes, scalars, and sub names.

        -Joe