title: Magento - memory error trying to get thumbnail
body: <p><strong>Edit</strong>: I'm using Magento 1.6.2 (community)</p>
  
  <p>I want to iterate over products. I run the following code (althought this is not a full file, it is part of a SOAP service's class definition - methods not described here are not important to my issue):</p>
  
  <pre><code>//ok
  private function _listProductData($product, $full = false)
  {
      $result = array(
          //_getProductAttribute($product, $attribute)
          'product_id'  =&gt; $product-&gt;getId(),
          'type'        =&gt; $product-&gt;getTypeId(),
          'position'    =&gt; $product-&gt;getCatIndexPosition(),
          'sku'         =&gt; $product-&gt;getSku(),
          'price'       =&gt; $this-&gt;_getProductAttribute($product, 'price'),
          'kilometraje' =&gt; $this-&gt;_getProductAttribute($product, 'kilometraje'),
          'thumbnail'   =&gt; Mage::helper('catalog/image')-&gt;init($product, 'thumbnail'),
          'model'       =&gt; $this-&gt;_getProductModel($product)
      );
  
      if ($full)
      {
          //meter mas datos
          $result = $result + array(
              'image' =&gt; $this-&gt;_getProductAttribute($product, 'small_image'),
              'tipo_vehiculo' =&gt; $this-&gt;_getProductAttribute($product, 'vehiculo_tipo', true),
              'cilindrada' =&gt; $this-&gt;_getProductAttribute($product, 'cilindrada', true),
              'combustible' =&gt; $this-&gt;_getProductAttribute($product, 'combustible', true),
              'transmision' =&gt; $this-&gt;_getProductAttribute($product, 'transmision', true),
              'direccion' =&gt; $this-&gt;_getProductAttribute($product, 'direccion', true),
              'traccion' =&gt; $this-&gt;_getProductAttribute($product, 'traccion', true),
              'anio' =&gt; $this-&gt;_getProductAttribute($product, 'rango_anio', true),
              'tapiz' =&gt; $this-&gt;_getProductAttribute($product, 'tapiz', true),
              'aire_acondicionado' =&gt; $this-&gt;_getProductAttribute($product, 'aire_acondicionado', true),
              'vidrios' =&gt; $this-&gt;_getProductAttribute($product, 'vidrios', true),
              'origen' =&gt; $this-&gt;_getProductAttribute($product, 'origen', true),
              'numero_placa' =&gt; $this-&gt;_getProductAttribute($product, 'numero_placa', true),
              'placa' =&gt; $this-&gt;_getProductAttribute($product, 'placa')
          );
      }
  
      //$result = array();
      //foreach ($product-&gt;getTypeInstance(true)-&gt;getEditableAttributes($product) as $attribute) {
      //    if ($this-&gt;_isAllowedAttribute($attribute, $attributes)) {
      //        $result[$attribute-&gt;getAttributeCode()] = $product-&gt;getData($attribute-&gt;getAttributeCode());
      //    }
      //}
      return $result;
  }
  
  //ok
  private function _listProductCollection($collection, $offset, $order)
  {
      //ordenamos y nos quedamos con un cachito de la coleccion nomas
      $order = in_array($order, array('ASC', 'DESC', false)) ? $order : false;
      $order ? $collection-&gt;setOrder('name', $order) : false;
      $collection-&gt;setPage($offset, 10);
      //iteramos y recolectamos los datos (TO-DO listar los atributos y la imagen principal)
      $result = array();
      foreach ($collection as $product) {
          $result[] = $this-&gt;_listProductData($product, false);
      }
  
      return $result;
  }
  
  //ok
  public function listVehicles($categoryId=null, $offset=1, $order='ASC')
  {
      $categoryId = (int) $categoryId;
      $offset = (int) $offset;
  
      if (($categoryId &lt; 1) || ($offset &lt; 1) || !in_array($order, array('DESC', 'ASC'))) {
          $this-&gt;_fault('bad_params');
      }
  
      //cargamos categoria actual, y store actual (1).
      //la categoria no puede ser de una rama que no sea Marcas o Tipos.
      //si eso pasa, o la categoria no existe, tiramos un 404.
      $category = $this-&gt;_initCategory($categoryId, 1);
      $parentId = $category-&gt;getParentId();
      if (!in_array($parentId, array(4, 94))) {
          $this-&gt;_fault('category_not_exists');
      }
      //tratamos su lista de resultado.
      return $this-&gt;_listProductCollection($category-&gt;setStoreId($storeId = 1)-&gt;getProductCollection()-&gt;addAttributeToSelect('*'), $offset, $order);
  }
  </code></pre>
  
  <p>To get the images of each individual item, I used to let the line <code>$this-&gt;_getProductAttribute($product, 'thumbnail')</code>, but it returned a relative url like: <code>/p/c/pcd0748-1.jpg</code> (url only illustrative).  </p>
  
  <p>When I tried to get the full url, by knowing its base url so I only have to append the chunk, I found such base url is not so "stable" (i.e. is not a well-known folder structure, but something related to cache):</p>
  
  <p><a href="http://www.blablabla.com/media/catalog/product/cache/1/small_image/201x201/17f82f742ffe127f42dca9de82fb58b1/p/c/pcd0748-1.jpg" rel="nofollow">http://www.blablabla.com/media/catalog/product/cache/1/small_image/201x201/17f82f742ffe127f42dca9de82fb58b1/p/c/pcd0748-1.jpg</a></p>
  
  <p>So I cannot simply take that long url as base url because of the hash - the common sense tells us that this base url will change.</p>
  
  <p>So I changed the image retrieval line to the currently given (<code>Mage::helper('catalog/image')-&gt;init($product, 'thumbnail')</code>) <strong>and I'm getting a memory error</strong> (I get a subset of 10 products, so such line is run 10 times in total).</p>
  
  <p><code>Fatal error:  Allowed memory size of 314572800 bytes exhausted (tried to allocate 295698398 bytes) ...</code> (¡¡¡295MB for 10 images!!!)</p>
  
  <p>Is there a more performant way that doesn't kill my memory for 10 images? I know such images exist, and just want to get the image urls.</p>