in reply to How to implement a Queue that doesn't leak memory?
use Devel::Peek; my $n = 1_000_000; my @q; for ( 1 .. $n ) { push @q, undef; shift @q; } Dump( @q );
SV = PVAV(0x5588bbfb50c0) at 0x5588bbfe31b8 REFCNT = 1 FLAGS = () ARRAY = 0x5588bbfee1d0 (offset=4) ALLOC = 0x5588bbfee1b0 FILL = -1 MAX = -1 FLAGS = (REAL)
offset + MAX + 1 gives the size of the array buffer, which is 4. The memory "leak" described by the linked post does not exist.
Doesn't change anything if you prevent it from becoming empty.
|
|---|