Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/private/Preview/Generator.php6
-rw-r--r--tests/lib/Preview/GeneratorTest.php5
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index f7aed987d89..e47a7e5927c 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -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 \OC_Image) {
+ $maxPreviewImage->destroy();
+ }
+
return $preview;
}
diff --git a/tests/lib/Preview/GeneratorTest.php b/tests/lib/Preview/GeneratorTest.php
index 3a46447632d..5e9b9bcbb8d 100644
--- a/tests/lib/Preview/GeneratorTest.php
+++ b/tests/lib/Preview/GeneratorTest.php
@@ -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);