Inline::Python seems to leak memory with dictionaries using unicode keys (so with dictionaries using u'foo' keys on Python 2.7 and all dictionaries on Python 3.5). To replicate:
inline_python_memory_leak.pl:
#!/usr/bin/env perl
use strict;
use warnings;
my $count = 0;
while ( 1 ) {
++$count;
my $dict = python_dictionary();
if ( $count % 10_000 == 1 ) {
say STDERR "Getting Python dictionary for the $count time...";
}
}
use Inline Python => <<'PYTHON';
def python_dictionary():
return {
'aaaaaaaaaaaa': { 'bbbbbbbbbb': [ 'ccccccccccc', 'ddddddddddd' ] },
}
PYTHON
Test with Inline::Python built against Python 2.7:
INLINE_PYTHON_EXECUTABLE=python2.7 cpanm --reinstall Inline::Python
perl inline_python_memory_leak.pl
# VIRT and RES usage stays stable
Test with Inline::Python built against Python 3.5:
INLINE_PYTHON_EXECUTABLE=python3.5 cpanm --reinstall Inline::Python
perl inline_python_memory_leak.pl
# VIRT and RES usage grows indefinitely until system starts swapping
Tested on OS X 10.12.1 with Perl v5.24.0, same behavior on Ubuntu 12.04 / 16.04.
Hello,
Inline::Python seems to leak memory with dictionaries using
unicode
keys (so with dictionaries usingu'foo'
keys on Python 2.7 and all dictionaries on Python 3.5). To replicate:inline_python_memory_leak.pl
:Tested on OS X 10.12.1 with Perl v5.24.0, same behavior on Ubuntu 12.04 / 16.04.