diff --git a/doc/source/whatsnew/v1.3.4.rst b/doc/source/whatsnew/v1.3.4.rst index 9c9aacc4b0f52..b6ee2d57a0965 100644 --- a/doc/source/whatsnew/v1.3.4.rst +++ b/doc/source/whatsnew/v1.3.4.rst @@ -35,6 +35,7 @@ Bug fixes ~~~~~~~~~ - Fixed bug in :meth:`.GroupBy.mean` with datetimelike values including ``NaT`` values returning incorrect results (:issue:`43132`) - Fixed bug in :meth:`Series.aggregate` not passing the first ``args`` to the user supplied ``func`` in certain cases (:issue:`43357`) +- Fixed memory leaks in :meth:`Series.rolling.quantile` and :meth:`Series.rolling.median` (:issue:`43339`) .. --------------------------------------------------------------------------- diff --git a/pandas/_libs/window/aggregations.pyx b/pandas/_libs/window/aggregations.pyx index 1941a3c4a37f0..98201a6f58499 100644 --- a/pandas/_libs/window/aggregations.pyx +++ b/pandas/_libs/window/aggregations.pyx @@ -835,6 +835,7 @@ def roll_median_c(const float64_t[:] values, ndarray[int64_t] start, if not is_monotonic_increasing_bounds: nobs = 0 + skiplist_destroy(sl) sl = skiplist_init(win) skiplist_destroy(sl) @@ -1070,6 +1071,7 @@ def roll_quantile(const float64_t[:] values, ndarray[int64_t] start, if i == 0 or not is_monotonic_increasing_bounds: if not is_monotonic_increasing_bounds: nobs = 0 + skiplist_destroy(skiplist) skiplist = skiplist_init(win) # setup