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

perf: fix loader memory leak from non-destroyed source map consumers #537

Merged
merged 2 commits into from
Nov 22, 2021

Conversation

pmmmwh
Copy link
Owner

@pmmmwh pmmmwh commented Nov 21, 2021

This fixes a memory leak in the loader when source map generation is required - it will now properly cleanup instances of SourceMapConsumer and maintain decent performance when the number of files increases.

Fixes #255
Fixes #524
Fixes #536

Co-authored-by: Serkan Yerşen <serkanyersen@gmail.com>
@pmmmwh pmmmwh added the bug Something isn't working label Nov 21, 2021
@serkanyersen
Copy link
Contributor

Thanks for the fix! I've tested this locally and it works. However, I think SourceMapConsumer.with is adding some overhead :/

my local test results show this

SourceMapConsumer.with consumer.destroy()
2 minutes 1.70 - 1.80 minutes

I think the size of our repo is amplifying whatever overhead with function has. Looking at their implementation I couldn't identify anything specific, it could just be the added delay on calling the destroy

This is an output of 1-2 runs though. can you give me some time to benchmark them with hyperfine. I'll let you know by tomorrow.

@serkanyersen
Copy link
Contributor

Never mind, it was just my computer being weird. they are the same. 😄

Screen Shot 2021-11-20 at 9 36 00 PM

loader/index.js Outdated Show resolved Hide resolved
@pmmmwh pmmmwh merged commit 77be80c into main Nov 22, 2021
@pmmmwh pmmmwh deleted the perf/source-maps branch November 22, 2021 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

slowness with loader + sourcemaps hot refresh become slower after upgrade to webpack5 Performance
2 participants