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

Fixes #222: A memory leak in DashboardData. #224

Merged
merged 2 commits into from
Aug 6, 2018

Conversation

mikkokar
Copy link
Contributor

@mikkokar mikkokar commented Aug 3, 2018

Fixes #222, a memory leak in dashboard data supplier.

The leak was caused by DashobardData.Origin objects being continuously registered to the message bus, but never unregistered.

@mikkokar mikkokar requested review from kvosper and dvlato August 3, 2018 14:54
this.backends = stream(backendServicesRegistry.get().spliterator(), false)
private List<Backend> updateBackendsFromRegistry() {
if (this.backends != null) {
this.backends.forEach(Backend::unregister);
Copy link
Contributor

Choose a reason for hiding this comment

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

this could just be

if (this.backends != null) {
  unregister();
}

@@ -206,6 +225,13 @@ private Backend(BackendService application) {
this.responsesSupplier = new ResponseCodeSupplier(metrics, METER, prefix, true);
}

void unregister() {
registeredOrigins.forEach(origin -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have a new field registeredOrigins that contains the same list as the existing field List<Origin> origin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is so that we unregister only those origins that actually have been registered.
I noticed that in some test cases (DashboardDataSupplier) the origins list contained different origins to those from registeredOrigins. But this could have been just a unusual or unrealistic dependency injection in the test itself.


dashbaord.unregister();

verify(eventBus, times(4)).register(any(DashboardData.Origin.class));
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be verifying that the origins were unregistered, not registered again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point.

@mikkokar
Copy link
Contributor Author

mikkokar commented Aug 3, 2018

Note, this is required as a bug fix for styx 0.7.n branches only. We will not cherry pick to styx 1.0 branch as it will have a brand new implementation for dashboard data supplier.

@mikkokar mikkokar merged commit d8d256f into ExpediaGroup:master Aug 6, 2018
@mikkokar
Copy link
Contributor Author

Will cherry pick to 1.0 as the refactoring is likely to be delayed.

@mikkokar mikkokar deleted the issue-222-fix-memory-leak branch August 31, 2018 08:16
mikkokar added a commit to mikkokar/styx that referenced this pull request Aug 31, 2018
mikkokar added a commit that referenced this pull request Aug 31, 2018
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.

3 participants