Re: Memory issues
- From: Jürgen Exner <jurgenex@xxxxxxxxxxx>
- Date: Sat, 29 Mar 2008 15:23:58 GMT
jm <jm@xxxxxxxxx> wrote:
Joost Diepenmaat a écrit :
jm <jm@xxxxxxxxx> writes:
Based on the fact that perl contains many memory leaks,
It doesn't.
I wrote a sample of code to illustrate the issue.
The code create a 10 mega characters string. this is the only big data
in this sample.
Which subsequently you copy a few times.
Then, the main part of the code just modify this data; that mean thatNo, they don't modify the string at all, they modify a _copy_ of the
memory usage should (in my humble opinion) stay near of 10 or 20 (or 40)
mega bytes.
The main program does not manipulate directly the string, but makes
functions aa and ab to manipulate this string. Those two functions aa
and ab just make substitutions within the string.
original string.
----- Script: ------------------------------------------
sub aa($)
{
my ($d) = @_;
And here you create a copy of the original string.
$d =~ s/x(.....)/$1y/g ;
$d =~ s/x(.....)/$1z/g ;
$d =~ s/x(.....)/$1a/g ;
$d =~ s/x(.....)/$1b/g ;
$d =~ s/x(.....)/$1c/g ;
return $d;
You return that copy ...
}
my $c= 'x' x (1000*1000*10) ;
$c .= "\x{1234}" ;
print length($c) ."\n" ;
my $v = qx( ps v $$ );
print "$v\n" ;
$c = aa($c);
....and you save that copy in $c, such that the memory cannot be reused.
The rest of the code seems to duplicate that action several times using
successively updated versions of the string as function argument, such
that successivly new copies of the string are created.
jue
.
- References:
- Memory issues
- From: jm
- Re: Memory issues
- From: Joost Diepenmaat
- Re: Memory issues
- From: jm
- Memory issues
- Prev by Date: Re: Memory issues
- Next by Date: Re: empty variables - getting rid of "uninitialized value" warnings?
- Previous by thread: Re: Memory issues
- Next by thread: Re: Memory issues
- Index(es):
Relevant Pages
|