Subject: | Memory cycle in fix_config |
Hi,
Looks like there's an unintentional memory cycle in the fix_config sub:
my $tmp = $config->{header};
$config->{header} = sub {
my $header = &$tmp;
return (ref $header eq 'HASH')
? lcr($header,$config->{pagewidth},'header')->()
: $header;
}
This is capturing the $config variable, causing a memory leak in long-running code.
Possible fixes could include:
* Pass the $config object to the header/footer callbacks
* Extract $config->{pagewidth} out to a $pagewidth variable (i.e. take the current value, rather than looking it up from the callback)
Originally reported by flamey in https://www.reddit.com/r/perl/comments/71otee/memory_leak_and_a_bug_in_textautoformat_i_guess/