Memory leak in List :: MoreUtils' each_array () and each_arrayref ()?

I just discovered an unpleasant memory leak using both each_array () and each_arrayref () from List :: MoreUtils.

These three lines of code are part of a routine executed four thousand times each time it starts. My goal is to give the correct format to the values ​​already in the hash. I have a fixed number of hash keys and a format string for each hash key.

my %hash = (); # ... my $two_arrays = each_arrayref( $field_list, $field_list_format ); while ( my ( $field, $format ) = $two_arrays->() ) { $hash{ $field } = sprintf $format, $hash{ $field }; } 

If I stick with return; until my $two_arrays ... , the leak disappears. The same return; past the last line causes a leak.

Since the subroutine is part of the daemon program, I noticed a continuous increase in memory (both VIRT and RES).

Something I did wrong? Is there a memory leak of each_array () or each_arrayref () I don't know?

  • List :: MoreUtil (Version 0.22)
  • Perl 5.12.1 (x86_64 with threads) on Linux 2.6.32-32-generic (Ubuntu 10.04)
+4
source share
1 answer

List :: MoreUtil (version 0.22) is dated July 2006, 5 years ago. Current version 0.32, is there a leak in this version? In recent versions, several memory leaks have been fixed: http://cpansearch.perl.org/src/ADAMK/List-MoreUtils-0.32/Changes

+7
source

All Articles