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

PL_perl_destruct_level coredump + memory leaks

Thread Next
From:
Larry Bressler
Date:
December 28, 2001 13:42
Subject:
PL_perl_destruct_level coredump + memory leaks
Message ID:
051501c18fe8$9b11e370$6401a8c0@LARRY
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) larry.cc - program to test memory leaks in embedded Perl.
 2) larry.pm - pm file invoked from larry.cc
 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 larry.cc.

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
Contact: lnbressler@mediaone.net

Many thanks to anyone who can help.

Larry


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About