Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak of RefMutContainer when using infinite loop #37

Merged
merged 2 commits into from
Jun 28, 2023

Conversation

jopemachine
Copy link
Member

@jopemachine jopemachine commented Jun 28, 2023

I tested this patch on only just simple test like below example yet,

>>> import rraft
>>> c = rraft.Config()
>>> r1 = c.make_ref()
>>> r2 = c.make_ref()
>>> c = None
>>> r1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
rraft.DestroyedRefUsedError: Cannot use a destroyed object's reference!
>>> r2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
rraft.DestroyedRefUsedError: Cannot use a destroyed object's reference!
>>> c = rraft.Config()
>>> r1 = None
Object removed: '1'
>>> r2 = None
Object removed: '2'
>>> c
Config { id: 0, election_tick: 20, heartbeat_tick: 2, applied: 0, max_size_per_msg: 0, max_inflight_msgs: 256, check_quorum: false, pre_vote: false, min_election_tick: 0, max_election_tick: 0, read_only_option: Safe, skip_bcast_commit: false, batch_append: false, priority: 0, max_uncommitted_size: 18446744073709551615, max_committed_size_per_ready: 18446744073709551615 }
>>> r1
>>> r2

@jopemachine
Copy link
Member Author

jopemachine commented Jun 28, 2023

The Object removed: statement is for debugging in this PR.
FYI, It might be printed later than expected, for seeing the debugging statement in this case, we could use gc.collect() here.

@jopemachine jopemachine marked this pull request as ready for review June 28, 2023 07:19
@jopemachine jopemachine changed the title PoC: Try to fix memory leak of RefMutContainer when using infinite loop Fix memory leak of RefMutContainer when using infinite loop Jun 28, 2023
@jopemachine jopemachine merged commit ae32f60 into main Jun 28, 2023
2 checks passed
@jopemachine jopemachine deleted the fix-memory-leak-on-refmutcontainer branch June 28, 2023 07:27
@jopemachine jopemachine added bug Something isn't working important labels Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working important
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant