[Zope] pyperl leaks memory
Solomon Bessire
sbessire@sssonline.com
Wed, 23 Oct 2002 09:17:54 -0700
The following Python script leaks about 8MB on my system (Debian Woody, Perl 5.6.1, Python 2.1.3, pyperl-1.0.1). Python's cyclic garbage collection is enabled. Perl is compiled w/o threads. pyperl is compiled w/o MULTI_PERL.
#!/usr/bin/env python
import perl
# create 100000 empty perl arrays and immediately discard them.
for x in range(100000):
perl.array(())
The MULTI_PERL code (that does not get used because of the singly-threaded Perl) appears to have a reference counting scheme. For those of you with multi-threaded Perl, does the previous program leak/consume substantial memory?
Is there some way to force garbage collection or manually decrement the reference count?
Is there an extra reference stored because of the shared Python/Perl object that prevents either the Perl or Python GC routines from garbage collecting the unused objects?
I've gotten around the problem by running the leaky code in a fork, but that's sloppy and shouldn't be necessary.
pyperl can be found at: http://downloads.activestate.com/Zope-Perl/pyperl-1.0.1.tar.gz if you're interested.
Thank you.