| 1 |
Perl Module Devel::Cycle |
| 2 |
======================== |
| 3 |
|
| 4 |
This module can be used to find memory cycles in objects and other |
| 5 |
references. Here is the synopsis: |
| 6 |
|
| 7 |
#!/usr/bin/perl |
| 8 |
use Devel::Cycle; |
| 9 |
|
| 10 |
# create an object that has four cycles |
| 11 |
my $test = {fred => [qw(a b c d e)], |
| 12 |
ethel => [qw(1 2 3 4 5)], |
| 13 |
george => {martha => 23, |
| 14 |
agnes => 19} |
| 15 |
}; |
| 16 |
# cycle 1 |
| 17 |
$test->{george}{phyllis} = $test; |
| 18 |
# cycle 2 |
| 19 |
$test->{fred}[3] = $test->{george}; |
| 20 |
# cycles 3 and 4 |
| 21 |
$test->{george}{mary} = $test->{fred}; |
| 22 |
find_cycle($test); |
| 23 |
exit 0; |
| 24 |
|
| 25 |
# output of the script: |
| 26 |
|
| 27 |
Cycle (1): |
| 28 |
HASH(0x8171d30)->{george} => HASH(0x8171d00) |
| 29 |
HASH(0x8171d00)->{phyllis} => HASH(0x8171d30) |
| 30 |
|
| 31 |
Cycle (2): |
| 32 |
HASH(0x8171d30)->{george} => HASH(0x8171d00) |
| 33 |
HASH(0x8171d00)->{mary} => ARRAY(0x814be60) |
| 34 |
ARRAY(0x814be60)->[3] => HASH(0x8171d00) |
| 35 |
|
| 36 |
Cycle (3): |
| 37 |
HASH(0x8171d30)->{fred} => ARRAY(0x814be60) |
| 38 |
ARRAY(0x814be60)->[3] => HASH(0x8171d00) |
| 39 |
HASH(0x8171d00)->{phyllis} => HASH(0x8171d30) |
| 40 |
|
| 41 |
Cycle (4): |
| 42 |
HASH(0x8171d30)->{fred} => ARRAY(0x814be60) |
| 43 |
ARRAY(0x814be60)->[3] => HASH(0x8171d00) |
| 44 |
HASH(0x8171d00)->{mary} => ARRAY(0x814be60) |
| 45 |
|
| 46 |
|
| 47 |
INSTALLATION |
| 48 |
|
| 49 |
To install this module type the following: |
| 50 |
|
| 51 |
perl Makefile.PL |
| 52 |
make |
| 53 |
make test |
| 54 |
make install |
| 55 |
|
| 56 |
DEVELOPING |
| 57 |
|
| 58 |
The master repository for Devel::Cycle is kept on GitHub at |
| 59 |
https://github.com/lstein/Devel-Cycle. Please contribute by sending |
| 60 |
pull requests. |
| 61 |
|
| 62 |
COPYRIGHT AND LICENCE |
| 63 |
|
| 64 |
Copyright (C) 2003-2014 by Lincoln Stein <[email protected]> |
| 65 |
|
| 66 |
This library is free software; you can redistribute it and/or modify |
| 67 |
it under the same terms as Perl itself, either Perl version 5.8.2 or, |
| 68 |
at your option, any later version of Perl 5 you may have available. |
| 69 |
|
| 70 |
|