Skip to content

Commit 9be55ce

Browse files
committed
BUG: Repeated time-series plot causes memory leak
1 parent 1a709c3 commit 9be55ce

File tree

5 files changed

+443
-312
lines changed

5 files changed

+443
-312
lines changed

doc/source/whatsnew/v0.17.0.txt

+10
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,29 @@ Performance Improvements
6060
Bug Fixes
6161
~~~~~~~~~
6262

63+
6364
- Bug in ``Categorical`` repr with ``display.width`` of ``None`` in Python 3 (:issue:`10087`)
6465

6566

67+
<<<<<<< HEAD
6668
- Bug where Panel.from_dict does not set dtype when specified (:issue:`10058`)
69+
=======
70+
- Bug in time-series plot causes memory leak (:issue:`9003`)
71+
72+
73+
>>>>>>> BUG: Repeated time-series plot causes memory leak
6774
- Bug in ``Timestamp``'s' ``microsecond``, ``quarter``, ``dayofyear``, ``week`` and ``daysinmonth`` properties return ``np.int`` type, not built-in ``int``. (:issue:`10050`)
6875
- Bug in ``NaT`` raises ``AttributeError`` when accessing to ``daysinmonth``, ``dayofweek`` properties. (:issue:`10096`)
6976

77+
7078
- Bug in getting timezone data with ``dateutil`` on various platforms ( :issue:`9059`, :issue:`8639`, :issue:`9663`, :issue:`10121`)
7179

7280

7381

82+
7483
- Bug in ``DatetimeIndex`` and ``TimedeltaIndex`` names are lost after timedelta arithmetics ( :issue:`9926`)
7584

7685
- Bug in `Series.plot(label="LABEL")` not correctly setting the label (:issue:`10119`)
7786

7887

88+

pandas/tests/test_graphics.py

+29
Original file line numberDiff line numberDiff line change
@@ -3425,6 +3425,35 @@ def test_sharey_and_ax(self):
34253425
self.assertTrue(ax.yaxis.get_label().get_visible(),
34263426
"y label is invisible but shouldn't")
34273427

3428+
def test_memory_leak(self):
3429+
""" Check that every plot type gets properly collected. """
3430+
import weakref
3431+
import gc
3432+
3433+
results = {}
3434+
for kind in plotting._plot_klass.keys():
3435+
args = {}
3436+
if kind in ['hexbin', 'scatter', 'pie']:
3437+
df = self.hexbin_df
3438+
args = {'x': 'A', 'y': 'B'}
3439+
elif kind == 'area':
3440+
df = self.tdf.abs()
3441+
else:
3442+
df = self.tdf
3443+
3444+
# Use a weakref so we can see if the object gets collected without
3445+
# also preventing it from being collected
3446+
results[kind] = weakref.proxy(df.plot(kind=kind, **args))
3447+
3448+
# have matplotlib delete all the figures
3449+
tm.close()
3450+
# force a garbage collection
3451+
gc.collect()
3452+
for key in results:
3453+
# check that every plot was collected
3454+
with tm.assertRaises(ReferenceError):
3455+
# need to actually access something to get an error
3456+
results[key].lines
34283457

34293458

34303459
@tm.mplskip

0 commit comments

Comments
 (0)