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

Investigate Realm close lifecycle #2198

Closed
nirinchev opened this issue Jan 22, 2021 · 1 comment · Fixed by #2251
Closed

Investigate Realm close lifecycle #2198

nirinchev opened this issue Jan 22, 2021 · 1 comment · Fixed by #2251
Assignees

Comments

@nirinchev
Copy link
Member

Looking at the code for State.RemoveRealm:

public bool RemoveRealm(Realm realm)
{
var weakRealm = _weakRealms.SingleOrDefault(r =>
{
return r.TryGetTarget(out var other) && ReferenceEquals(realm, other);
});
_weakRealms.Remove(weakRealm);
if (!_weakRealms.Any())
{
realm.SharedRealmHandle.CloseRealm();
return true;
}
return false;
}

It looks like we may end up in a situation where we have 2 instances - X and Y; X gets GC-ed and Y - disposed. When RemoveRealm is called for Y, it'll see there're still instances in State._weakRealms and avoid closing the native Realm.

@nirinchev nirinchev self-assigned this Feb 15, 2021
@sync-by-unito
Copy link

sync-by-unito bot commented Jun 17, 2021

➤ Brian Munkholm commented:

This looks to be unblocked now.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant