Skip to content
Snippets Groups Projects
Commit 56ed563b authored by Elijah Martin-Merrill's avatar Elijah Martin-Merrill
Browse files

fix memory leak caused by not destroying image in Preview/Generate.php

parent 4cac0f68
No related branches found
No related tags found
No related merge requests found
......@@ -192,6 +192,12 @@ class Generator {
}
}
// Free memory being used by the embedded image resource. Without this the image is kept in memory indefinitely.
// Garbage Collection does NOT free this memory. We have to do it ourselves.
if ($maxPreviewImage instanceof IImage) {
$maxPreviewImage->destroy();
}
return $preview;
}
......
......@@ -31,7 +31,6 @@ use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\IConfig;
use OCP\IImage;
use OCP\IPreview;
use OCP\Preview\IProviderV2;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
......@@ -183,7 +182,7 @@ class GeneratorTest extends \Test\TestCase {
$this->fail('Unexpected provider requested');
});
$image = $this->createMock(IImage::class);
$image = $this->createMock(\OC_Image::class);
$image->method('width')->willReturn(2048);
$image->method('height')->willReturn(2048);
$image->method('valid')->willReturn(true);
......@@ -318,7 +317,7 @@ class GeneratorTest extends \Test\TestCase {
}
private function getMockImage($width, $height, $data = null) {
$image = $this->createMock(IImage::class);
$image = $this->createMock(\OC_Image::class);
$image->method('height')->willReturn($width);
$image->method('width')->willReturn($height);
$image->method('valid')->willReturn(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment