Description
Bug summary
In Triangulation
, when calling get_trifinder
, the trifinder is stored is self._trifinder
, however TriFinder
itself also stores a reference to the triangulation in self._triangulation
. As a result, neither object is ever destroyed.
Code for reproduction
import matplotlib.tri as tri
import numpy as np
import psutil
n_points = 500000
x = np.random.rand(n_points) * 100
y = np.random.rand(n_points) * 100
while True:
triangulation = tri.Triangulation(x, y)
trifinder = triangulation.get_trifinder()
mem = psutil.virtual_memory().available * 100 / psutil.virtual_memory().total
print(f"Available memory: {mem:.2f}%")
Actual outcome
Available memory: 75.65%
Available memory: 69.80%
Available memory: 63.91%
Available memory: 58.04%
Available memory: 52.15%
Available memory: 46.27%
Available memory: 40.40%
Available memory: 34.53%
Available memory: 28.65%
Available memory: 22.87%
Available memory: 17.03%
Available memory: 11.12%
Available memory: 6.25%
Available memory: 0.95%
Available memory: 0.62%
Available memory: 0.73%
Available memory: 0.95%
Available memory: 0.90%
Killed
Expected outcome
The memory should remain the same after each iteration.
Additional information
The _triangulation
attribute in TriFinder is never actually used and can be safely removed: this fixes the issue.
Operating system
Linux (Debian 12), Windows
Matplotlib Version
3.9.0
Matplotlib Backend
qtagg
Python version
3.11.2
Jupyter version
7.1.2
Installation
pip