Skip to content

Conversation

@sl0thentr0py
Copy link
Member

@sl0thentr0py sl0thentr0py commented Sep 22, 2025

We cannot use weakref always since built-in exception types like ZeroDivisionError raise a TypeError.
This makes the memory usage at least a little better for custom exception types.

Issues

@sl0thentr0py sl0thentr0py requested a review from a team as a code owner September 22, 2025 09:34
@linear
Copy link

linear bot commented Sep 22, 2025

@codecov
Copy link

codecov bot commented Sep 22, 2025

✅ All tests passed in 2585.21s

cursor[bot]

This comment was marked as outdated.

@sl0thentr0py sl0thentr0py force-pushed the neel/make-dedupe-memory-efficient branch 2 times, most recently from 89ea5eb to a7529ed Compare September 22, 2025 11:27
cursor[bot]

This comment was marked as outdated.

@sl0thentr0py sl0thentr0py force-pushed the neel/make-dedupe-memory-efficient branch from a7529ed to d24da87 Compare September 22, 2025 11:43
@sl0thentr0py sl0thentr0py changed the title Try simpler dedupe logic Use weakref in dedupe where possible Sep 22, 2025
@sl0thentr0py
Copy link
Member Author

with the fix in this PR, the code from #3165 (comment)

gives

before

(.venv) [neel@vheissu vanilla]$ python app.py 
ERROR:root:Exception logging
Traceback (most recent call last):
  File "/run/media/neel/m2/sentry/sentry_sample_apps/python/vanilla/app.py", line 16, in <module>
    raise CustomException('Custom Exception')
CustomException: Custom Exception
Custom Exception
Custom Exception
Custom Exception
Custom Exception
Custom Exception
Custom Exception
Custom Exception
Custom Exception
Custom Exception
Custom Exception
^CException was garbage collected!

after

(.venv) [neel@vheissu vanilla]$ python app.py 
ERROR:root:Exception logging
Traceback (most recent call last):
  File "/run/media/neel/m2/sentry/sentry_sample_apps/python/vanilla/app.py", line 16, in <module>
    raise CustomException('Custom Exception')
CustomException: Custom Exception
Exception was garbage collected!
None
None
None
None

Copy link
Contributor

@antonpirker antonpirker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@sl0thentr0py sl0thentr0py merged commit 34a3580 into master Sep 22, 2025
118 of 119 checks passed
@sl0thentr0py sl0thentr0py deleted the neel/make-dedupe-memory-efficient branch September 22, 2025 12:03
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.

Memory leak during exception logging

2 participants