Hi all (and Perrin),

I understand the concepts being discussed here.

However, no on replied one of my questions:

Let's conside this script:

#******************************************
use strict;
package mypack;

my $tmp;
$tmp .= 'a';
print '$tmp value: ' . $tmp . ' - address: ' . \$tmp . "\n";
#******************************************

I am running this script in a ModPerl::Registry environment.

In this situation, the first time I'm running the script, I can see this:

main $tmp: a - address: SCALAR(0xd725e0)

And then, in subsequent calls:

$tmp value: a - address: SCALAR(0xd77bf4)
$tmp value: a - address: SCALAR(0xd77d20)
$tmp value: a - address: SCALAR(0xd77d38)

Of course, I understand why $tmp value is reset during each call (the
lexical variable goes out of scope) but, as we can see, the address used by
the variable is changing as well during each request, and this fact doesn't
seem consistent with what has been said before (i.e. that memory stayed
allocated to lexical variables across requests)...

I would have believed that, for the sake of efficiency (and that's why memory allocated to lexical variables is not released to Perl), the exact same memory location would have been used by the lexical variable in subsequent calls.

So, obviously, as the memory is not released, and as new memory blocks are used for every call to host the lexical, this seems to me to be memory leak.

Am I wrong or am I missing something?

Lionel.

I suppose I am still missing something, but what?

Lionel.


Reply via email to