Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

pathUtils | joinCache memory leak #414

Open
Galcarmi opened this issue Apr 24, 2024 · 6 comments · May be fixed by #418
Open

pathUtils | joinCache memory leak #414

Galcarmi opened this issue Apr 24, 2024 · 6 comments · May be fixed by #418

Comments

@Galcarmi
Copy link

Hey guys,

We use webpack in our services to bundle code.
A webpack compiler is being created for each bundling process by importing webpack creator function from webpack.
Webpack is using enhanced-resolve to resolve module paths.. We also have custom resolvers that extends ResolvePluginInstance which is a enhanced-resolve resolver AFAIK.
Those resolvers are injected to webpack using the plugins property

After a while, we saw that as the service bundle code a memory leak is increasing in our service.
(for each bundle a new compiler of webpack is created)

As you can see in the heap-dump picture, it is related to joinCache property.
Screenshot 2024-04-24 at 15 05 00

This property can be found here. this is a non-exported global variable that never cleans.

As I can see it, you can help us in 2 ways,

  1. Clean this Map every X interval (it will be amazing if you can provide a configuration for it)
  2. Provide a function that cleans that cache and we will call it after every bundle process.

LMK if you need any further data/explanations,
Thanks 🙏🏼🙏🏼

@alexander-akait
Copy link
Member

Oh, it was for cache, how many run do you have?

@Galcarmi
Copy link
Author

@alexander-akait The service runs (potentially) infinite bundling processes

@Galcarmi
Copy link
Author

Galcarmi commented Apr 25, 2024

I can create a PR for adding a clearCache function, WDYT?

By the way, there is a third option to use LRU cache object with fixed size

@Galcarmi
Copy link
Author

@alexander-akait 🙏🏼

@Galcarmi Galcarmi linked a pull request Apr 30, 2024 that will close this issue
@Galcarmi
Copy link
Author

created a fork with the fix
#418
i'll try it on my servers and update..

@Galcarmi
Copy link
Author

Galcarmi commented May 2, 2024

Well, seems like it works, can we do something similar for enhanced-resolve?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants