Skip to content

Commit 9c49dfa

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

File tree

5 files changed

+444
-316
lines changed

5 files changed

+444
-316
lines changed

doc/source/whatsnew/v0.17.0.txt

+6
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,26 @@ Bug Fixes
6262

6363
- Bug where read_hdf store.select modifies the passed columns list when
6464
multi-indexed (:issue:`7212`)
65+
6566
- Bug in ``Categorical`` repr with ``display.width`` of ``None`` in Python 3 (:issue:`10087`)
6667

6768

6869
- Bug where Panel.from_dict does not set dtype when specified (:issue:`10058`)
70+
71+
6972
- Bug in ``Timestamp``'s' ``microsecond``, ``quarter``, ``dayofyear``, ``week`` and ``daysinmonth`` properties return ``np.int`` type, not built-in ``int``. (:issue:`10050`)
7073
- Bug in ``NaT`` raises ``AttributeError`` when accessing to ``daysinmonth``, ``dayofweek`` properties. (:issue:`10096`)
7174

75+
7276
- Bug in getting timezone data with ``dateutil`` on various platforms ( :issue:`9059`, :issue:`8639`, :issue:`9663`, :issue:`10121`)
7377
- Bug in display datetimes with mixed frequencies uniformly; display 'ms' datetimes to the proper precision. (:issue:`10170`)
7478

7579

80+
7681
- Bug in ``DatetimeIndex`` and ``TimedeltaIndex`` names are lost after timedelta arithmetics ( :issue:`9926`)
7782

7883
- Bug in `Series.plot(label="LABEL")` not correctly setting the label (:issue:`10119`)
7984
- Bug in `plot` not defaulting to matplotlib `axes.grid` setting (:issue:`9792`)
8085

8186

87+

pandas/tests/test_graphics.py

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

3466+
def test_memory_leak(self):
3467+
""" Check that every plot type gets properly collected. """
3468+
import weakref
3469+
import gc
3470+
3471+
results = {}
3472+
for kind in plotting._plot_klass.keys():
3473+
args = {}
3474+
if kind in ['hexbin', 'scatter', 'pie']:
3475+
df = self.hexbin_df
3476+
args = {'x': 'A', 'y': 'B'}
3477+
elif kind == 'area':
3478+
df = self.tdf.abs()
3479+
else:
3480+
df = self.tdf
3481+
3482+
# Use a weakref so we can see if the object gets collected without
3483+
# also preventing it from being collected
3484+
results[kind] = weakref.proxy(df.plot(kind=kind, **args))
3485+
3486+
# have matplotlib delete all the figures
3487+
tm.close()
3488+
# force a garbage collection
3489+
gc.collect()
3490+
for key in results:
3491+
# check that every plot was collected
3492+
with tm.assertRaises(ReferenceError):
3493+
# need to actually access something to get an error
3494+
results[key].lines
34663495

34673496
@slow
34683497
def test_df_grid_settings(self):

0 commit comments

Comments
 (0)