or download this
Some of the data that makes up the objects returned from the Ensembl A
+PI is lazy loaded. By using lazy loading, we are able to minimize the
+ number of database queries and only "fill in" the data in the object
+ that the program actually asked for. This makes the code faster and
+its memory footprint smaller, but it also means that the more data th
+at the program requests from an object the larger it becomes. The con
+sequence of this is that looping over a large number of these objects
+ in some cases might grow the memory footprint of the program conside
+rably.
By using a while-shift loop rather than a foreach loop, the growth of
+the memory footprint due to lazy loading of data is more likely to st
+ay small. This is why the comment on the last loop above says that it
+ is a "more memory efficient way", and this is also why we use this c
+onvention for most similar loop constructs in the remainder of this A
+PI tutorial.
NB: This strategy obviously won't work if the contents of the list bei
+ng iterated over is needed at some later point after the end of the l
+oop.