Closed MagicDuck closed 6 years ago
I will create a PR soon.
Think this can be closed since https://github.com/webpack/webpack-sources/pull/31 was merged.
Thanks @MagicDuck
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...
The code in
ConcatSource::source()
andReplaceSource::_replaceString()
is usingarray.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: