"be consistent" | |
PerlMonks |
Re^7: references--hard vs anonymous operational weirdnessby hipowls (Curate) |
on Mar 24, 2008 at 10:02 UTC ( [id://675879]=note: print w/replies, xml ) | Need Help?? |
Thanks for your reply. I now understand where I went wrong. Just to try and reduce the degree of bafflement going round I'll explain my (admittedly erroneous) thinking. On each iteration of the loop the (simplified) process is
A smart compiler can optimize that loop so that the allocation and deallocation of the memory occur outside the loop, that is only once. Based on my observation of the actual memory allocation I had assumed that perl was optimizing the loop in just such a manner. Perl, however, is not that simple and its loop would be more like
So what I was seeing was a chunk of memory deallocated and then an immediate request for a chunk of the same type and the memory manager handed over the chunk just released.
In Section
Seekers of Perl Wisdom
|
|