in reply to memory "release" with $#=-1
In other words, the memory is free to reuse by the same perl process, but not for other processes on your system.
I've tested this using these 3 simple scripts, and you can see doing a ps -o vsz,command | grep perl (or similar type of command, adapt to your OS, in my case it's FreeBSD), that in the first 2 cases the memory usage by the relevant perl processes is the same:
#!/usr/bin/perl use strict; # case 1: array uses a lot of memory, and goes out of scope $0 = "highmemusage_going_out_of_scope"; { my @aap = map { $_ * $_ } ( 0 .. 100000 ); } sleep 300;
#!/usr/bin/perl use strict; # case 2: array uses a lot of memory, and stays in scope $0 = "highmemusage_staying_in_scope"; my @aap = map { $_ * $_ } ( 0 .. 100000 ); sleep 300;
Anybody more familiar with perl memory allocation please correct me if I'm wrong,#!/usr/bin/perl use strict; # case 3: use as baseline mem usage of your perl $0 = "reference"; sleep 300;
|
|---|