Skip to content

Commit c3b1325

Browse files
authored
Manually clean up memory for some tests that don't call solve (#4983)
1 parent 1ba8790 commit c3b1325

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

tests/firedrake/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
os.environ["FIREDRAKE_DISABLE_OPTIONS_LEFT"] = "1"
1010

1111
import pytest
12+
from mpi4py import MPI
1213
from petsctools import get_external_packages
1314
from pyadjoint.tape import (
1415
annotate_tape, get_working_tape, set_working_tape,
@@ -256,3 +257,10 @@ def __exit__(self, exc_type, exc_val, traceback):
256257
def petsc_raises():
257258
# This function is needed because pytest does not support classes as fixtures.
258259
return _petsc_raises
260+
261+
262+
@pytest.fixture
263+
def garbage_cleanup():
264+
"""Fixture that runs the parallel garbage collector."""
265+
yield
266+
PETSc.garbage_cleanup(MPI.COMM_WORLD)

tests/firedrake/output/test_io_function.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
func_name = "f"
1717

1818

19+
@pytest.fixture(autouse=True)
20+
def autouse_garbage_cleanup(garbage_cleanup):
21+
pass
22+
23+
1924
def _initialise_function(f, _f, method):
2025
if method == "project":
2126
getattr(f, method)(_f, solver_parameters={"ksp_type": "cg", "pc_type": "sor", "ksp_rtol": 1.e-16})

tests/firedrake/regression/test_covariance_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def rng():
3939
@pytest.mark.parametrize("family", ("CG", "DG"))
4040
@pytest.mark.parametrize("mesh_type", ("interval", "square"))
4141
@pytest.mark.parametrize("backend_type", (PyOP2NoiseBackend, PetscNoiseBackend), ids=("pyop2", "petsc"))
42-
def test_white_noise(family, degree, mesh_type, dim, backend_type, rng):
42+
def test_white_noise(family, degree, mesh_type, dim, backend_type, rng, garbage_cleanup):
4343
"""Test that white noise generator converges to a mass matrix covariance.
4444
"""
4545

0 commit comments

Comments
 (0)