Skip to content

Commit be4a59d

Browse files
authored
Explicitly unset images during tearDown() (#150)
To facilitate debugging of possible refleaks.
1 parent e2874ce commit be4a59d

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

src/Config.php

+3
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,9 @@ private static function init(): void
781781
self::$gobject = \FFI::cdef($gobject_decls, $gobject_libname);
782782
self::$vips = \FFI::cdef($vips_decls, $vips_libname);
783783

784+
# Useful for debugging
785+
# self::$vips->vips_leak_set(1);
786+
784787
# force the creation of some types we need
785788
self::$vips->vips_blend_mode_get_type();
786789
self::$vips->vips_interpretation_get_type();

tests/ConvenienceTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ protected function setUp(): void
2424
$this->pixel = $this->image->getpoint(0, 0);
2525
}
2626

27+
protected function tearDown(): void
28+
{
29+
unset($this->image);
30+
unset($this->pixel);
31+
}
32+
2733
public function testVipsBandjoin()
2834
{
2935
$image = Vips\Image::newFromArray([[1, 2, 3], [4, 5, 6]]);

tests/ExceptionTest.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ class ExceptionTest extends TestCase
1212
*/
1313
private $image;
1414

15-
/**
16-
* The original value of pixel (0, 0).
17-
*/
18-
private $pixel;
19-
2015
protected function setUp(): void
2116
{
2217
$filename = __DIR__ . '/images/img_0076.jpg';
2318
$this->image = Vips\Image::newFromFile($filename);
24-
$this->pixel = $this->image->getpoint(0, 0);
19+
}
20+
21+
protected function tearDown(): void
22+
{
23+
unset($this->image);
2524
}
2625

2726
public function testVipsNewFromFileException()

tests/MetaTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ protected function setUp(): void
2626
$this->png_image = Vips\Image::newFromFile($png_filename);
2727
}
2828

29+
protected function tearDown(): void
30+
{
31+
unset($this->image);
32+
unset($this->png_image);
33+
}
34+
2935
public function testVipsSetGet()
3036
{
3137
$this->image->poop = 'banana';

tests/ShortcutTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ protected function setUp(): void
3737
$this->pixel = $this->image->getpoint(0, 0);
3838
}
3939

40+
protected function tearDown(): void
41+
{
42+
unset($this->image);
43+
unset($this->pixel);
44+
}
45+
4046
public function testVipsPow()
4147
{
4248
$real = self::mapNumeric($this->pixel, function ($value) {

0 commit comments

Comments
 (0)