Memory tests behave differently on one vs. several tests
Opened this issue ยท 1 comments
tommyod commented
There seems to be some state or overhead when running multiple memray tests.
- Running all three tests in one go reports high memory usage for the first one, lower for the remaining two tests
- Running one at a time reports a relatively high memory usage for each test
Running all tests
pytest tests -k memory --memray
==================================================================================== MEMRAY REPORT ===
Allocation results for tests/test_esmda.py::TestESMDAMemory::test_ESMDA_memory_usage_subspace_inversion_without_overwrite at the high watermark
๐ฆ Total memory allocated: 127.2MiB
๐ Total allocations: 194
๐ Histogram of allocation sizes: |โ โ โ โ|
Allocation results for tests/test_sies.py::test_memory_usage at the high watermark
๐ฆ Total memory allocated: 63.8MiB
๐ Total allocations: 237
๐ Histogram of allocation sizes: |โ โ โ
โ|
Allocation results for tests/test_esmda.py::TestESMDAMemory::test_ESMDA_memory_usage_subspace_inversion_with_overwrite at the high watermark
๐ฆ Total memory allocated: 54.8MiB
๐ Total allocations: 156
๐ Histogram of allocation sizes: |โ โ
โ|
Running individually
pytest tests -k test_ESMDA_memory_usage_subspace_inversion_without_overwrite --memray
==================================================================================== MEMRAY REPORT ===
Allocation results for tests/test_esmda.py::TestESMDAMemory::test_ESMDA_memory_usage_subspace_inversion_without_overwrite at the high watermark
๐ฆ Total memory allocated: 127.2MiB
๐ Total allocations: 194
๐ Histogram of allocation sizes: |โ โ โ โ|
pytest tests -k test_memory_usage --memray
==================================================================================== MEMRAY REPORT ===
Allocation results for tests/test_sies.py::test_memory_usage at the high watermark
๐ฆ Total memory allocated: 127.8MiB
๐ Total allocations: 255
๐ Histogram of allocation sizes: |โ โ
โ โ โ|
pytest tests -k test_ESMDA_memory_usage_subspace_inversion_with_overwrite --memray
==================================================================================== MEMRAY REPORT ===
Allocation results for tests/test_esmda.py::TestESMDAMemory::test_ESMDA_memory_usage_subspace_inversion_with_overwrite at the high watermark
๐ฆ Total memory allocated: 118.8MiB
๐ Total allocations: 186
๐ Histogram of allocation sizes: |โ โ โ โ|
tommyod commented
There also seems to be a bit of state between runs:
<change the test>
(venv) > $ pytest tests --memray -k test_esmda_inversion_memory
==================================================================================== MEMRAY
Allocation results for tests/test_esmda_inversion.py::test_esmda_inversion_memory at the high watermark
๐ฆ Total memory allocated: 128.2MiB
(venv) > $ pytest tests --memray -k test_esmda_inversion_memory
==================================================================================== MEMRAY
Allocation results for tests/test_esmda_inversion.py::test_esmda_inversion_memory at the high watermark
๐ฆ Total memory allocated: 127.2MiB