I am using latest release of marpa::r2 (Marpa-R2-2.065_002) and it seems to eat all memory very fast. I wrote the bellow script 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 ~ [a-z]+
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 the memory leaks?
Edit: This is now reported as a bug to rt.cpan.
Edit: It is now fixed on release Marpa-R2 2.066000. Thanks
perl -MMarpa::R2 -e'*M:: = *Marpa::R2::Scanless::; my $g = M::G->new({source => \q(:start ::= A A ::= [ ])}); M::R->new({grammar => $g}) for 1 .. 1E5'
. Have you already filed a bug? – Plasterwork