diff --git a/asv_bench/benchmarks/rolling.py b/asv_bench/benchmarks/rolling.py index 659b6591fbd4b..7aefad6e2929b 100644 --- a/asv_bench/benchmarks/rolling.py +++ b/asv_bench/benchmarks/rolling.py @@ -113,4 +113,20 @@ def time_quantile(self, constructor, window, dtype, percentile, self.roll.quantile(percentile, interpolation=interpolation) +class PeakMemFixed(object): + + def setup(self): + N = 10 + arr = 100 * np.random.random(N) + self.roll = pd.Series(arr).rolling(10) + + def peakmem_fixed(self): + # GH 25926 + # This is to detect memory leaks in rolling operations. + # To save time this is only ran on one method. + # 6000 iterations is enough for most types of leaks to be detected + for x in range(6000): + self.roll.max() + + from .pandas_vb_common import setup # noqa: F401 diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 94f8fd16ea85a..6502063c71125 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -372,6 +372,7 @@ Groupby/Resample/Rolling - Bug in :func:`pandas.core.groupby.GroupBy.agg` when applying a aggregation function to timezone aware data (:issue:`23683`) - Bug in :func:`pandas.core.groupby.GroupBy.first` and :func:`pandas.core.groupby.GroupBy.last` where timezone information would be dropped (:issue:`21603`) - Ensured that ordering of outputs in ``groupby`` aggregation functions is consistent across all versions of Python (:issue:`25692`) +- Bug in :meth:`pandas.core.window.Rolling.min` and :meth:`pandas.core.window.Rolling.max` that caused a memory leak (:issue:`25893`) - Bug in :func:`idxmax` and :func:`idxmin` on :meth:`DataFrame.groupby` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) diff --git a/pandas/_libs/window.pyx b/pandas/_libs/window.pyx index cc5b3b63f5b04..29a21c06c064e 100644 --- a/pandas/_libs/window.pyx +++ b/pandas/_libs/window.pyx @@ -1263,7 +1263,7 @@ cdef _roll_min_max(ndarray[numeric] values, int64_t win, int64_t minp, return _roll_min_max_variable(values, starti, endi, N, win, minp, is_max) else: - return _roll_min_max_fixed(values, starti, endi, N, win, minp, is_max) + return _roll_min_max_fixed(values, N, win, minp, is_max) cdef _roll_min_max_variable(ndarray[numeric] values, @@ -1349,8 +1349,6 @@ cdef _roll_min_max_variable(ndarray[numeric] values, cdef _roll_min_max_fixed(ndarray[numeric] values, - ndarray[int64_t] starti, - ndarray[int64_t] endi, int64_t N, int64_t win, int64_t minp,