garu / Clone

recursively copy Perl datatypes
7 stars 10 forks source link

Memory leak #42

Open dpanech opened 1 year ago

dpanech commented 1 year ago

Leaks memory when passed an expression that returns a non-existent hash value (which should be effectively undef). For example the following loop leaks ~70 MiB per second on my system.

use Clone;
my $data = {};
while(1) {
    Clone::clone ($data->{no_such_key});
};

However if you save the hash value in an intermediate variable, it doesn't leak:

use Clone;
my $data = {};
while(1) {
    my $tmp = $data->{no_such_key};
    Clone::clone ($tmp);
};

Environment I was able to reproduce it in these environments: