public function upload() { if (!Input::hasFile('image')) { return $this->respondNotFound('Image not found'); } $this->log('Started'); $this->log(memory_get_usage(true)); $attachment = new Image(); $this->file = Input::file('image'); $this->log('Init origin image'); $image = new ImageUtil($this->file); $this->log(memory_get_usage(true)); $this->log('Uploading origin image'); $this->log(memory_get_usage(true)); $attachment->origin = $this->uploadImage2($image->getImage()); $this->log(memory_get_usage(true)); // preventMemoryLeak(); $this->log('Garbage collector'); $this->log(memory_get_usage(true)); $this->log('Gallery image upload'); $attachment->regular = $this->uploadImage2($image->resize2('gallery')->getImage()); $this->log(memory_get_usage(true)); $this->log('Destroying gallery image'); $image->getImage()->destroy(); $image = null; $this->log(memory_get_usage(true)); // preventMemoryLeak(); $this->log('Garbage collector'); $this->log(memory_get_usage(true)); $this->log('Init thumbnail image'); $thumb = new ImageUtil($this->file); $thumb->resize2('thumbnail'); $this->log(memory_get_usage(true)); $this->log('uploading thumbnail image'); $attachment->thumbnail = $this->uploadImage2($thumb->getImage()); $this->log(memory_get_usage(true)); // preventMemoryLeak(); $this->log('Garbage collector'); $this->log(memory_get_usage(true)); $attachment->width = $thumb->getWidth(); $attachment->height = $thumb->getHeight(); $this->log('Destroying the thumb image'); $thumb->getImage()->destroy(); $thumb = null; $this->log(memory_get_usage(true)); $attachment->save(); return $this->respond($this->collectionTransformer->transformImage($attachment)); }