Skip to content

fix: Break reference cycle between Actor and ActorRef#251

Merged
jodal merged 1 commit intomainfrom
fix-ref-cycle
Mar 14, 2026
Merged

fix: Break reference cycle between Actor and ActorRef#251
jodal merged 1 commit intomainfrom
fix-ref-cycle

Conversation

@jodal
Copy link
Copy Markdown
Owner

@jodal jodal commented Mar 14, 2026

Actor and ActorRef both had references to each other, creating a cycle that blocked instant memory freeing since the actor's reference count never reached zero.

This changes the ActorRef reference to the actor to use a weakref, so that the ActorRef doesn't contribute to the actor's reference count, enabling instant freeing of the memory.

Fixes #249, #250

Actor and ActorRef both had references to each other, creating a cycle
that blocked instant memory freeing since the actor's reference count
never reached zero.

This changes the ActorRef reference to the actor to use a weakref, so
that the ActorRef doesn't contribute to the Actor's reference count,
enabling instant freeing of the memory.

Fixes #249, #250
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 14, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.84%. Comparing base (4168837) to head (b78ce94).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/pykka/_proxy.py 25.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #251      +/-   ##
==========================================
- Coverage   94.32%   93.84%   -0.48%     
==========================================
  Files          14       14              
  Lines         581      585       +4     
  Branches       50       51       +1     
==========================================
+ Hits          548      549       +1     
- Misses         29       31       +2     
- Partials        4        5       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jodal jodal merged commit 0bef0e4 into main Mar 14, 2026
11 of 13 checks passed
@jodal jodal deleted the fix-ref-cycle branch March 14, 2026 10:55
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.

Actor not garbage collected after stop

1 participant