in reply to Re^6: references--hard vs anonymous operational weirdness
in thread references--hard vs anonymous operational weirdness
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
- Allocate memory for @array
- Initialize @array
- Deallocate memory assigned to @array
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
- Allocate memory for @array
- Initialize @array
- Deallocate memory assigned to @array if not referred to else where
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^8: references--hard vs anonymous operational weirdness
by ikegami (Patriarch) on Mar 24, 2008 at 18:34 UTC | |
by hipowls (Curate) on Mar 24, 2008 at 21:20 UTC | |
by ikegami (Patriarch) on Mar 25, 2008 at 03:47 UTC |