Secondo voi come mai questo codice funziona solo con immagini piccole e non funge con quelle superiori a 300 Kb?

Codice PHP:
$filename $newfile;

header('Content-type: image/jpeg');

list(
$width$height) = getimagesize($filename);
$newwidth 800;
$newheight 600;

// Load
$thumb imagecreatetruecolor($newwidth$newheight);
$source imagecreatefromjpeg($filename);

// Resize
imagecopyresampled($thumb$source0000$newwidth$newheight$width$height);

// Output
imagejpeg($thumb,"prova.jpg");