Finding 'lost' variables (circular references)

前端 未结 1 1074
栀梦
栀梦 2021-02-09 00:53

So, it\'s a bit of a simplistic case - but if I set up a circular reference like this:

#!/usr/bin/perl
use strict;
use warnings;

{ 
   my $thing; 
   my $othert         


        
相关标签:
1条回答
  • 2021-02-09 01:22

    This is just a curation of the modules recommended in the comments on the question. It includes a link to each module's POD documentation, and quotes the name and description sections. It is meant to be accessible. Nowhere have I added to or changed what the author wrote, or pulled information from anywhere other than the name and description sections

    Anyone is welcome to update it with additional modules as long as they keep to this format. Alternatively, anyone may draw my attention to the fact that it needs to be updated and I will do so when I am able

    Many great programmers are not so great with English so, while I have tried to quote the documentation exactly, I have cut what I believe to be less relevant sections in keeping with the purpose of this post

    Devel::Cycle - Find memory cycles in objects

    This is a simple developer's tool for finding circular references in objects and other types of references. Because of Perl's reference-count based memory management, circular references will cause memory leaks.

    Devel::LeakTrace::Fast - Indicate where leaked variables are coming from.

    Devel::LeakTrace::Fast is a rewrite of Devel::LeakTrace. Like Devel::LeakTrace it uses the pluggable runops feature found in perl 5.6 and later in order to trace SV allocations of a running program.

    At END time Devel::LeakTrace::Fast identifies any remaining variables, and reports on the lines in which the came into existence.

    Devel::Gladiator - Walk Perl's arena

    Devel::Gladiator iterates Perl's internal memory structures and can be used to enumerate all the currently live SVs.

    This can be used to hunt leaks and to profile memory usage.

    Devel::MAT::Dumper - Write a heap dump file for later analysis

    This module provides the memory-dumping function that creates a heap dump file which can later be read by Devel::MAT::Dumpfile. It provides a single function which is not exported, which writes a file to the given path.

    The dump file will contain a representation of every SV in Perl's arena, providing information about pointers between them, as well as other information about the state of the process at the time it was created. It contains a snapshot of the process at that moment in time, which can later be loaded and analysed by various tools using Devel::MAT::Dumpfile.

    Devel::Peek - A data debugging tool for the XS programmer

    Devel::Peek contains functions which allows raw Perl datatypes to be manipulated from a Perl script. This is used by those who do XS programming to check that the data they are sending from C to Perl looks as they think it should look.

    0 讨论(0)
提交回复
热议问题