Skip to content

Conversation

@Zain-Mahmoud
Copy link
Contributor

@Zain-Mahmoud Zain-Mahmoud commented Feb 10, 2026

Proposed Changes

This PR aims to fix the issue where repeated calls to the PyTA check_all() function cause the memory usage of the process to increase with each call (issue #646).

...

Screenshots of your changes (if applicable)

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📚 Documentation update (change that only updates documentation)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • I have updated the project Changelog (this is required for all changes).
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

(Include any questions or comments you have regarding your changes.)

@Zain-Mahmoud
Copy link
Contributor Author

Investigation

import io
import tracemalloc
import python_ta

def run_runner():
    buf = io.StringIO()
    python_ta.check_all(output=buf)

tracemalloc.start()

for i in range(5000):
    run_runner()
    current = tracemalloc.get_traced_memory()
    print(f"{i} | {int(current[0] / 1024**2)} MB")

Running the above code snippet, we can see that the memory usage does in fact increase with each call:

0 | 42 MB
1 | 44 MB
2 | 46 MB
3 | 48 MB
4 | 49 MB
5 | 51 MB
6 | 53 MB
7 | 55 MB
8 | 56 MB
9 | 58 MB
...
91 | 121 MB
92 | 122 MB
93 | 124 MB
94 | 125 MB
95 | 127 MB
96 | 128 MB
97 | 130 MB
98 | 132 MB
99 | 133 MB
...

But there does seem to be some freeing of memory (approximately 20 or so MB) every ~20 calls.

I also checked both Pylint and Astroid's changelogs but I couldn't find any fixes related to any memory leak issues.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant