When %matplotlib inline is ON gc.collect() runs on every cell execution · Issue #5795 · ipython/ipython · GitHub
Skip to content

When %matplotlib inline is ON gc.collect() runs on every cell execution #5795

Description

@kmike

Hi,

I'm not sure if it is the best place to put this issue. I'm working on an IPython notebook with a lot of objects loaded: len(gc.get_objects()) is about 5M. Everything works fine until an inline plot is drawn. Drawing itself is fast, but then there is a delay (5-10s). The delay is caused by gc.collect() executed by matplotlib: https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/_pylab_helpers.py#L93. After the first plot the notebook becomes slow for all cells (even without inline plots). When interrupting the kernel (for cells without plots) I can see the same gc.collect() happening inside matplotlib.

As a workaround I'm monkey-patching gc.collect to be no-op, but this is clearly a hack.

It is gc.collect() call in matplotlib code that makes things slow, but why does IPython notebook need to call matplotlib code for cells without charts?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions