Hola, estoy tratando de crear un archivo php que seleccione todos los archivos JPG del directorio donde esta guardado y me cree nuevos archivos JPG de un tamaño diferente. 
 
Ejemplo: en el directorio donde esta guardado mi archivo php, llamado thumbs.php,  tengo una imagen de nombre "imagen.php" el script me genera una nueva imagen de nombre "thumb_imagen.php" de la mitad de su tamaño; y asi sucesivamente con las demas imagenes del directorio. 
Esta funcionando, pero luego de hacer varias imagenes, y mas si tienen varios Kb, me aparece el siguiente error y deja de crear mas imagenes:  
 Código HTML:
 Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 512 bytes) in C:\AppServ\www\imagenes\thumbs\galeria\thumbs.php on line 9
 creo q no me tendria que aparecer ya que uso la funcion  
 Código PHP:
    imagedestroy($fuente);
imagedestroy($imagen); 
    
  Que estoy haciendo mal?? 
El codigo es:  
 Código PHP:
    <?php 
function imagenes_escala($archivo,$escala)
{
$fuente = imagecreatefromjpeg($archivo);
$imgAncho = imagesx($fuente);
$imgAlto =imagesy($fuente);
$ancho = $imgAncho*$escala;
$alto = $imgAlto*$escala;
$imagen = imagecreatetruecolor($ancho,$alto);
imagecopyresampled($imagen,$fuente,0,0,0,0,$ancho,$alto,$imgAncho,$imgAlto);
imagejpeg($imagen,"thumb_".$archivo);
imagedestroy($fuente);
imagedestroy($imagen);
}
?> 
<?php
$escala= 0.5;
$files = "";
$n=1;
foreach (glob("*.jpg") as $key => $fileName) 
{
$files[$n]= "$fileName";
$n=$n+1;
}
for ($u="1"; $u<"$n"; $u++)
    {
    $archivo = $files[$u];
    imagenes_escala($archivo,$escala);
    }
?>    
  Desde ya muchas gracias