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

fix: Replace Map with WeakMap to avoid memory leak #4517

Merged
merged 1 commit into from
Aug 8, 2023

Conversation

ceciliaavila
Copy link
Collaborator

#minor

Description

This PR replaces the use of Map with WeakMap in the LanguageGeneratorExtensions and ExpressionParser classes due to a memory leak issue reported in a JS Composer bot.

Specific Changes

  • Replaced Map _languageGeneratorManagers with WeakMap in LanguageGeneratorExtensions.
  • Replaced Map expressionDict with WeakMap in ExpressionParser. Also, changed the type of the key as WeakMap only supports objects.

Testing

The unit tests passed after the changes.
image

@ceciliaavila ceciliaavila requested a review from a team as a code owner August 8, 2023 18:50
@coveralls
Copy link

coveralls commented Aug 8, 2023

Pull Request Test Coverage Report for Build 5800804749

  • 4 of 5 (80.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.005%) to 84.852%

Changes Missing Coverage Covered Lines Changed/Added Lines %
libraries/adaptive-expressions/src/parser/expressionParser.ts 3 4 75.0%
Totals Coverage Status
Change from base Build 5797958645: -0.005%
Covered Lines: 20134
Relevant Lines: 22485

💛 - Coveralls

@ceciliaavila
Copy link
Collaborator Author

Hi @tracyboehrer, this PR contains the changes to use WeakMap instead of Map.
Let us know if you have any questions o comments.

@tracyboehrer tracyboehrer merged commit 5b58d10 into main Aug 8, 2023
13 checks passed
@tracyboehrer tracyboehrer deleted the southworks/update/map-for-weakmap branch August 8, 2023 20:52
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