Netflix / archaius

Library for configuration management API
Apache License 2.0
2.46k stars 485 forks source link

Fix memory leak caused by anonymous listeners in abandoned views #634

Closed akang31 closed 1 year ago

akang31 commented 1 year ago

Views created that depend on other views (Composite, Layered, and Prefixed) create listeners on the source view that update themselves. This reference to themselves prevents GC until the source view is abandoned, meaning creating unused dependent views is a memory and performance leak. This applies the WeakReference logic from the PrivateView to the other dependent view types in order to fix this leak.

There is a small bug in PrefixedViewConfig where we supposedly allow prefixes of form "foo" or "foo.", but any prefix of form "foo." will actually still assume form "foo", meaning that configs such as "foo.bar" would, in the prefixed view, be taken as configs of type "ar" instead of the expected "bar". I'll address this in a followup change in case there is anyone relying on this behavior.

akang31 commented 1 year ago

Updated the PR to remove the fixes to PrefixedViewConfig. I'll address that in a followup PR.