Marpa :: R2 memory leak

I am using the latest version of marpa :: r2 (Marpa-R2-2.065_002) and it seems to eat up all the memory very quickly. I wrote a script below to test it.

use strict; use warnings FATAL => 'all'; use Marpa::R2; use Data::Dumper; my $grammar = Marpa::R2::Scanless::G->new({ action_object => __PACKAGE__, source => \(<<'END_OF_SOURCE'), :default ::= action => ::array :start ::= path path ::= step action => _do_step step ~ [az]+ END_OF_SOURCE }); sub _do_step{ return {step => $_[1]}}; sub new {} #The Marpa::R2 needs it sub compile{ my ($query) = @_; return undef unless $query; my $reader = Marpa::R2::Scanless::R->new({ grammar => $grammar, trace_terminals => 0, }); $reader->read(\$query); print Dumper $reader->value; } compile($_) foreach ('aaaa'..'zzzz'); 

What can I do to prevent memory leak?

Edit: this is now reported as an rt.cpan error.

Edit: It is now fixed in Marpa-R2 2.066000 release. Thanks

+8
memory-leaks perl parsing marpa
source share
1 answer

The leak is fixed in Marpa-R2 2.065_006 on CPAN. Thank you for pointing this out and thanks to Amon for a minimal example that saved me time and eased the situation.

The problem was in the Perl code. Two structures contained links to each other - a circular link. Testing the fixed version using the amon example allows you to use memory without wasting time.

I will fix this fix in the indexed (i.e. non-development) version on CPAN as soon as possible.

+5
source share

All Articles