Subject: | Circular references |
It seems like CGI::FormBuilder has circular references that leaks
memory. Here's a test that you can use as part of your test suite.
use Test::Memory::Cycle;
use Test::More tests => 1;
use CGI::FormBuilder;
my $f = CGI::FormBuilder->new(
{
source => {type => 'File',
source => \"name: one\nfields:a,b"},
}
);
memory_cycle_ok($f);
twst@web [~/tmp/CGI-FormBuilder-3.05]# perl -Mblib t/4a-memory.t
1..1
not ok 1
# Failed test at t/4a-memory.t line 13.
# Cycle #1
# CGI::FormBuilder A->{fieldrefs} => %B
# %B->{a} => CGI::FormBuilder::Field C
# CGI::FormBuilder::Field C->{_form} => CGI::FormBuilder A
# Cycle #2
# CGI::FormBuilder A->{fieldrefs} => %B
# %B->{b} => CGI::FormBuilder::Field D
# CGI::FormBuilder::Field D->{_form} => CGI::FormBuilder A
# Cycle #3
# CGI::FormBuilder A->{fields} => @E
# @E->[0] => CGI::FormBuilder::Field C
# CGI::FormBuilder::Field C->{_form} => CGI::FormBuilder A
# Cycle #4
# CGI::FormBuilder A->{fields} => @E
# @E->[1] => CGI::FormBuilder::Field D
# CGI::FormBuilder::Field D->{_form} => CGI::FormBuilder A
# Looks like you failed 1 test of 1.