develooper Front page | perl.perl5.porters | Postings from December 2001

PL_perl_destruct_level coredump + memory leaks

Thread Next
Larry Bressler
December 28, 2001 13:42
PL_perl_destruct_level coredump + memory leaks
Message ID:
I have 2 problems with embedded perl that occur in both 5.6.1 and 5.7.2.
These occurred on Linux 2.4.2 (I got this from RedHat):

1) Huge memory leak - in many versions of Perl, including 5.6.1 and 5.7.2,
every time we invoke a .pm program we get a leak, as measured
using:      top -n 1 -p pid#
The next paragraph describes a workaround that works pretty well in
perl5.004_5, but causes a core dump in  newer versions of Perl.  It 
entails destroying  Perl and then reallocating after 100 or so invocations 
of the pm file.

2) "PL_perl_destruct_level = 1;"  causes a core dump in 5.6.1 and 5.7.2,
but not in perl5.004_05.   I don't know about versions in between.
If we periodically call perl_destruct() & perl_free() to free, and then 
perl_alloc() & perl_construct() to realloc in perl5.004_05, we dramatically
decrease the memory leaks. To do this successfully requires setting 
PL_perl_destruct_level = 1.    But in 5.6.1 and 5.7.2, 
setting PL_perl_destruct_level = 1 causes a core dump.

I have included 3 Linux files here that illustrate the 2 problems:
 1) - program to test memory leaks in embedded Perl.
 2) - pm file invoked from
 3) Makefile.larry - run with "make -f Makefile.larry"

The .cc  program loops and calls a trivial .pm program a bunch of times. 
Both the memory leak and the PL_perl_destruct_level problems
are illustrated in

Perl version tested: 5.6.1 and 5.7.2
OS - Linux 2.4.2 kernel (got from RedHat)
Author: Larry Bressler
Date: 12/27/01

Many thanks to anyone who can help.


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About