1Cycle(3) User Contributed Perl Documentation Cycle(3)
2
3
4
6 Test::Memory::Cycle - Check for memory leaks and circular memory
7 references
8
10 Version 1.06
11
13 Perl's garbage collection has one big problem: Circular references
14 can't get cleaned up. A circular reference can be as simple as two
15 references that refer to each other:
16
17 my $mom = {
18 name => "Marilyn Lester",
19 };
20
21 my $me = {
22 name => "Andy Lester",
23 mother => $mom,
24 };
25 $mom->{son} = $me;
26
27 "Test::Memory::Cycle" is built on top of "Devel::Cycle" to give you an
28 easy way to check for these circular references.
29
30 use Test::Memory::Cycle;
31
32 my $object = new MyObject;
33 # Do stuff with the object.
34 memory_cycle_ok( $object );
35
36 You can also use "memory_cycle_exists()" to make sure that you have a
37 cycle where you expect to have one.
38
40 "memory_cycle_ok( $reference, $msg )"
41 Checks that $reference doesn't have any circular memory references.
42
43 "memory_cycle_exists( $reference, $msg )"
44 Checks that $reference does have any circular memory references.
45
46 "weakened_memory_cycle_ok( $reference, $msg )"
47 Checks that $reference doesn't have any circular memory references, but
48 unlike "memory_cycle_ok" this will also check for weakened cycles
49 produced with Scalar::Util's "weaken".
50
51 "weakened_memory_cycle_exists( $reference, $msg )"
52 Checks that $reference does have any circular memory references, but
53 unlike "memory_cycle_exists" this will also check for weakened cycles
54 produced with Scalar::Util's "weaken".
55
57 Written by Andy Lester, "<andy @ petdance.com>".
58
60 Please report any bugs or feature requests to "bug-test-memory-cycle at
61 rt.cpan.org", or through the web interface at
62 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Memory-Cycle>. I
63 will be notified, and then you'll automatically be notified of progress
64 on your bug as I make changes.
65
67 You can find documentation for this module with the perldoc command.
68
69 perldoc Test::Memory::Cycle
70
71 You can also look for information at:
72
73 · AnnoCPAN: Annotated CPAN documentation
74
75 <http://annocpan.org/dist/Test-Memory-Cycle>
76
77 · CPAN Ratings
78
79 <http://cpanratings.perl.org/d/Test-Memory-Cycle>
80
81 · RT: CPAN's request tracker
82
83 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Memory-Cycle>
84
85 · Search CPAN
86
87 <http://search.cpan.org/dist/Test-Memory-Cycle>
88
90 Thanks to the contributions of Stevan Little, and to Lincoln Stein for
91 writing Devel::Cycle.
92
94 Copyright 2003-2016 Andy Lester.
95
96 This program is free software; you can redistribute it and/or modify it
97 under the terms of the Artistic License v2.0.
98
99 See http://www.perlfoundation.org/artistic_license_2_0 or the LICENSE
100 file that comes with the Test::Memory::Cycle distribution.
101
102
103
104perl v5.32.0 2020-07-28 Cycle(3)