Skip to content

fix leaking the KRPC addon on each scene switch#779

Merged
djungelorm merged 1 commit intokrpc:mainfrom
JonnyOThan:fix-server-leaks
Mar 12, 2024
Merged

fix leaking the KRPC addon on each scene switch#779
djungelorm merged 1 commit intokrpc:mainfrom
JonnyOThan:fix-server-leaks

Conversation

@JonnyOThan
Copy link
Contributor

by unhooking event handlers from static objects

@djungelorm
Copy link
Member

I don't follow how the leak occurs? Could you explain?

@JonnyOThan
Copy link
Contributor Author

When you register an event handler, the publisher of the event holds on to a reference to the subscriber object. If the subscriber has a shorter lifetime than the publisher, it needs to unsubscribe from those events or it will never be garbage collected because of the lingering references.

Lambdas are particularly tricky because you cannot easily remove them from an event.

@djungelorm djungelorm merged commit dafe268 into krpc:main Mar 12, 2024
@djungelorm djungelorm added this to the 0.6.0 milestone Mar 12, 2024
@djungelorm djungelorm added bug Something isn't working server labels Mar 12, 2024
@JonnyOThan JonnyOThan deleted the fix-server-leaks branch March 18, 2024 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants