File tree 5 files changed +440
-317
lines changed
5 files changed +440
-317
lines changed Original file line number Diff line number Diff line change @@ -408,7 +408,7 @@ Bug Fixes
408
408
- Bug in ``Series.plot(kind='hist')`` Y Label not informative (:issue:`10485`)
409
409
- Bug in ``read_csv`` when using a converter which generates a ``uint8`` type (:issue:`9266`)
410
410
411
-
411
+ - Bug causes memory leak in time-series line and area plot (:issue:`9003`)
412
412
413
413
414
414
- Bug in line and kde plot cannot accept multiple colors when ``subplots=True`` (:issue:`9894`)
Original file line number Diff line number Diff line change @@ -3281,6 +3281,36 @@ def test_sharey_and_ax(self):
3281
3281
self .assertTrue (ax .yaxis .get_label ().get_visible (),
3282
3282
"y label is invisible but shouldn't" )
3283
3283
3284
+ def test_memory_leak (self ):
3285
+ """ Check that every plot type gets properly collected. """
3286
+ import weakref
3287
+ import gc
3288
+
3289
+ results = {}
3290
+ for kind in plotting ._plot_klass .keys ():
3291
+ args = {}
3292
+ if kind in ['hexbin' , 'scatter' , 'pie' ]:
3293
+ df = self .hexbin_df
3294
+ args = {'x' : 'A' , 'y' : 'B' }
3295
+ elif kind == 'area' :
3296
+ df = self .tdf .abs ()
3297
+ else :
3298
+ df = self .tdf
3299
+
3300
+ # Use a weakref so we can see if the object gets collected without
3301
+ # also preventing it from being collected
3302
+ results [kind ] = weakref .proxy (df .plot (kind = kind , ** args ))
3303
+
3304
+ # have matplotlib delete all the figures
3305
+ tm .close ()
3306
+ # force a garbage collection
3307
+ gc .collect ()
3308
+ for key in results :
3309
+ # check that every plot was collected
3310
+ with tm .assertRaises (ReferenceError ):
3311
+ # need to actually access something to get an error
3312
+ results [key ].lines
3313
+
3284
3314
@slow
3285
3315
def test_df_grid_settings (self ):
3286
3316
# Make sure plot defaults to rcParams['axes.grid'] setting, GH 9792
You can’t perform that action at this time.
0 commit comments