René's URL Explorer Experiment


Title: apparent memory leak with live plotting · Issue #11956 · matplotlib/matplotlib · GitHub

Open Graph Title: apparent memory leak with live plotting · Issue #11956 · matplotlib/matplotlib

X Title: apparent memory leak with live plotting · Issue #11956 · matplotlib/matplotlib

Description: Bug report I've noticed that when running a matplotlib as a run-chart/long term plotting tool, memory use by matplotlib increases over the course of about a week, ultimately crashing the program. I'm continually updating my plot, but I a...

Open Graph Description: Bug report I've noticed that when running a matplotlib as a run-chart/long term plotting tool, memory use by matplotlib increases over the course of about a week, ultimately crashing the program. I...

X Description: Bug report I've noticed that when running a matplotlib as a run-chart/long term plotting tool, memory use by matplotlib increases over the course of about a week, ultimately crashing the progra...

Opengraph URL: https://github.com/matplotlib/matplotlib/issues/11956

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"apparent memory leak with live plotting","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\nI've noticed that when running a matplotlib as a run-chart/long term plotting tool, memory use by matplotlib increases over the course of about a week, ultimately crashing the program.  I'm continually updating my plot, but I am only plotting the most recent 100 data points (so that the data itself isn't contributing to the memory increase).  See an overly simplified example below that still shows the issue.  As you will see when running the code below, matplotlib\\transforms.py just continually increases by around 5-15 kb on each turn of the loop, despite clearing my axes and using the object oriented version of matplotlib.  This increase will continue to happen until it fills up the memory of my computer.  Is this intentional?  My thought was that in the object oriented program version of matplotlib, my code shouldn't increase in memory like this.\r\n\r\nMost of the code below is simply just tracemalloc helper functions for keeping track of memory.\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug, also minimizing the number of dependencies required--\u003e\r\n\r\n```python\r\n\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\nimport os\r\nimport linecache\r\nimport sys\r\nimport tracemalloc\r\nimport time\r\n\r\n\r\ndef display_top(snapshot, key_type='lineno', limit=2):\r\n    '''\r\n    function for pretty printing tracemalloc output\r\n    '''\r\n    snapshot = snapshot.filter_traces((\r\n        tracemalloc.Filter(False, \"\u003cfrozen importlib._bootstrap\u003e\"),\r\n        tracemalloc.Filter(False, \"\u003cunknown\u003e\"),\r\n    ))\r\n    top_stats = snapshot.statistics(key_type)\r\n\r\n    print(\"Top %s lines\" % limit)\r\n    for index, stat in enumerate(top_stats[:limit], 1):\r\n        frame = stat.traceback[0]\r\n        # replace \"/path/to/module/file.py\" with \"module/file.py\"\r\n        filename = os.sep.join(frame.filename.split(os.sep)[-2:])\r\n        print(\"#%s: %s:%s: %.1f KiB\"\r\n              % (index, filename, frame.lineno, stat.size / 1024))\r\n        line = linecache.getline(frame.filename, frame.lineno).strip()\r\n        if line:\r\n            print('    %s' % line)\r\n\r\n    other = top_stats[limit:]\r\n    if other:\r\n        size = sum(stat.size for stat in other)\r\n        print(\"%s other: %.1f KiB\" % (len(other), size / 1024))\r\n    total = sum(stat.size for stat in top_stats)\r\n    print(\"Total allocated size: %.1f KiB\" % (total / 1024))\r\n\r\ntracemalloc.start()\r\n\r\ny = np.random.rand(100)\r\nx = range(len(y))\r\n\r\n\r\nfig = plt.figure()\r\nax = fig.add_subplot(111)\r\nax.plot(x,y,'b-')\r\nplt.show(block=False)\r\n\r\nt0 = time.time()\r\n \r\nwhile True:\r\n    try:\r\n        ax.clear()\r\n        ax.plot(x,np.random.rand(100),'b-')\r\n        plt.pause(0.0001)\r\n        snapshot = tracemalloc.take_snapshot()\r\n        print(\"Run Time:\", time.time()-t0)\r\n        display_top(snapshot)\r\n        time.sleep(0.05)\r\n    except KeyboardInterrupt:\r\n        break\r\n\r\n```\r\n\r\nIf you'd prefer to use your own memory debugger, here's the simplest form of this issue:\r\n\r\n```python\r\n\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\nimport time\r\ny = np.random.rand(100)\r\nx = range(len(y))\r\n\r\nfig = plt.figure()\r\nax = fig.add_subplot(111)\r\nax.plot(x,y,'b-')\r\nplt.show(block=False)\r\n\r\nt0 = time.time()\r\n \r\nwhile True:\r\n    try:\r\n        ax.clear()\r\n        ax.plot(x,np.random.rand(100),'b-')\r\n        plt.pause(0.0001)\r\n        print(\"Run Time:\", time.time()-t0)\r\n        time.sleep(0.05)\r\n    except KeyboardInterrupt:\r\n        break\r\n```\r\n\r\n\r\nIn the console output, you'll see matplotlib\\transforms.py quickly become the largest memory holder, and increase continually.\r\n\r\nThis issue also appears if I use a line object and line.set_xdata, etc., rather than ax.plot().\r\n\r\nUsing WinPython, Python 3.6.2\r\nMatplotlib version 2.2.2\r\nWindows 7 and Windows 10\r\nBackend TkAgg\r\n\r\n","author":{"url":"https://github.com/mgeorgiadis","@type":"Person","name":"mgeorgiadis"},"datePublished":"2018-08-28T14:08:48.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/11956/matplotlib/issues/11956"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:87faee7b-01e5-4f92-55de-94f472fa7117
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA8BC:206F88:40AC98D:59B6803:6A54D565
html-safe-nonce17ee0839add387c7008e199221352ae6a6bf32ded547e3798c2265f8f97bed18
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOEJDOjIwNkY4ODo0MEFDOThEOjU5QjY4MDM6NkE1NEQ1NjUiLCJ2aXNpdG9yX2lkIjoiNzkyMTM5MDMyNjc2OTgzMzMxNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac51a8dfd20cc456f2fb9c3e2f40e87accee84eb3b9ab7d2a477fe94b7fc65c6ca
hovercard-subject-tagissue:354748860
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/11956/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e6a91dbaab8cfcaed4835db7197aaa50e53b3aa4227c4fcb7ef30441c8b3feb2/matplotlib/matplotlib/issues/11956
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e6a91dbaab8cfcaed4835db7197aaa50e53b3aa4227c4fcb7ef30441c8b3feb2/matplotlib/matplotlib/issues/11956
og:image:altBug report I've noticed that when running a matplotlib as a run-chart/long term plotting tool, memory use by matplotlib increases over the course of about a week, ultimately crashing the program. I...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemgeorgiadis
hostnamegithub.com
expected-hostnamegithub.com
Nonea556215b071af6609619e2bbe6f00bdfbf0812ad723b1ae6c301858a7a829f54
turbo-cache-controlno-preview
go-importgithub.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git
octolytics-dimension-user_id215947
octolytics-dimension-user_loginmatplotlib
octolytics-dimension-repository_id1385122
octolytics-dimension-repository_nwomatplotlib/matplotlib
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1385122
octolytics-dimension-repository_network_root_nwomatplotlib/matplotlib
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release840b5d20d5a883c23cf56f5240b2c343d6cc0867
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/issues/11956#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F11956
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F11956
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/issues/11956
Reloadhttps://github.com/matplotlib/matplotlib/issues/11956
Reloadhttps://github.com/matplotlib/matplotlib/issues/11956
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/11956
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/11956
Notifications https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Fork 8.4k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Star 23k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Code https://github.com/matplotlib/matplotlib
Issues 1.1k https://github.com/matplotlib/matplotlib/issues
Pull requests 409 https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality 0 https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
Code https://github.com/matplotlib/matplotlib
Issues https://github.com/matplotlib/matplotlib/issues
Pull requests https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
#11972https://github.com/matplotlib/matplotlib/pull/11972
apparent memory leak with live plottinghttps://github.com/matplotlib/matplotlib/issues/11956#top
#11972https://github.com/matplotlib/matplotlib/pull/11972
v3.1.0https://github.com/matplotlib/matplotlib/milestone/35
https://github.com/mgeorgiadis
mgeorgiadishttps://github.com/mgeorgiadis
on Aug 28, 2018https://github.com/matplotlib/matplotlib/issues/11956#issue-354748860
v3.1.0https://github.com/matplotlib/matplotlib/milestone/35
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.