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

[bugfix] Avoid memory leak in updateLocale #4561

Closed
wants to merge 2 commits into from

Conversation

ashsearle
Copy link
Contributor

Fixed #4476

@coveralls
Copy link

coveralls commented Apr 15, 2018

Coverage Status

Coverage decreased (-0.02%) to 94.43% when pulling fea9d51 on ashsearle:fix/4476 into 07d88ae on moment:develop.

@marwahaha
Copy link
Member

This looks good. Can we add a test that shows it fixes a potential memory leak?


if (locales[name] != null && locales[name].parentLocale != null) {
// Update existing child locale in-place to avoid memory-leaks
locales[name].set(config);
Copy link
Member

Choose a reason for hiding this comment

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

Does this require the config provided to updateLocale to be a complete config?

Copy link
Member

Choose a reason for hiding this comment

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

See, for example, #4438

Copy link
Contributor Author

@ashsearle ashsearle Apr 16, 2018

Choose a reason for hiding this comment

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

Good question... just because it doesn't break current unit-tests doesn't mean it's any good :-/

It probably needs to be slightly more hideous, like:

locales[name].set(mergeConfigs(locales[name]._config, config));

I'll try that when I get a chance.

@marwahaha
Copy link
Member

@ashsearle great. Could we add some tests to show that this change won't memory leak?

@marwahaha
Copy link
Member

Any updates @ashsearle ?

@ashsearle
Copy link
Contributor Author

Any updates @ashsearle ?

Not really.

It should be trivial to use leakage to wrap one of the updateLocale tests and check for memory leaks. But... I'm just wasting time fighting moment's rollup config and getting nowhere (I cannot figure out how to refer to any package installed in node_modules.)

@ichernev
Copy link
Contributor

Merged in ccd55f9

ichernev added a commit that referenced this pull request Apr 26, 2020
[bugfix] Avoid memory leak in updateLocale
@ichernev ichernev closed this Apr 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calls to moment.updateLocale increases the memory usage
4 participants