in reply to Re: Memory efficiency, anonymous vs named's vs local subroutines
in thread Memory efficiency, anonymous vs named's vs local subroutines
The ca. 750 extra bytes for named subs may well be just the cost of allocating a GLOB for the subroutine in the symbol table,
Running the code below to create a million STASH aliases to a single sub:
sub F123456{ my( $a, $b, $c )= @_; my $x = 123456; return $a * $b - $ +c; };; *{"X$_"} = \&F123456 for 0 .. 1e6;;
results in an increase in the process size of almost exactly 300MB, thus 300 bytes per STASH entry.
Some of the extra space may be down to unreused (but reusable) space allocated and freed during the doubling of the STASH hash as it grows. I can't think of any way to isolate that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Memory efficiency, anonymous vs named's vs local subroutines
by shmem (Chancellor) on Jul 19, 2015 at 07:21 UTC |