You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
remove unnecessary memory allocation from ConcatSource and ReplaceSource #30
The code in ConcatSource::source() and ReplaceSource::_replaceString() is using array.join("") which causes allocation of new strings. Using simple concatenation with += instead causes node to create what it calls something like "concatenated strings" internally which reuse the memory of the original strings being concatenated (this is probably possible since strings are immutable).
This problem was discovered by recording a "memory allocation profile" using chrome dev tools for the duration of the whole webpack build.
Before:
After change:
Reacted by Hugo Campos, Ryan Wong, Vasyl Zuziak, Adam Wamai Egesa and August “Kai” Kaiser
Reacted by Adam Wamai Egesa and August “Kai” Kaiser
Activity
MagicDuck commentedon Nov 24, 2017
I will create a PR soon.
using (+=) operator instead of array join/reduce to reduce memory all…
using (+=) operator instead of array join/reduce to reduce memory all…
using (+=) operator instead of array join/reduce to reduce memory all…
using (+=) operator instead of array join/reduce to reduce memory all…
filipesilva commentedon Nov 25, 2017
Think this can be closed since #31 was merged.
joshwiens commentedon Nov 25, 2017
Thanks @MagicDuck
MagicDuck commentedon Nov 25, 2017
No worries :)
There's a bunch more, on a more minor level, that i have seen in the source-list-map project. I want to see what can be done. The most bizarre one is this: https://github.com/webpack/source-list-map/blob/master/lib/helpers.js
I am not sure why dev tools is reporting getNumberOfLines as allocating tens of mb in my case...