GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Process aborts with 'out of memory' when using 2.0.0 · Issue #143 · webpack/minimizer-webpack-plugin

Process aborts with 'out of memory' when using 2.0.0 #143

New issue
Copy link
New issue
Copy link
Closed
#211
Closed
Process aborts with 'out of memory' when using 2.0.0#143
#211
Copy link

Description

@nick
nick
opened on Sep 6, 2019
Issue body actions
  • Operating System: OSX 10.14.6
  • Node Version: 10.16.0
  • NPM Version: 6.9.0
  • webpack Version: 4.39.3
  • terser-webpack-plugin Version: 2.0.0

Expected Behavior

Process does not abort

Actual Behavior

$ NODE_ENV=production ./node_modules/.bin/webpack --loglevel notice

<--- Last few GCs --->

[84294:0x102843000]    55749 ms: Mark-sweep 1312.4 (1444.3) -> 1305.0 (1446.3) MB, 622.0 / 0.0 ms  (average mu = 0.099, current mu = 0.040) allocation failure scavenge might not succeed
[84294:0x102843000]    56388 ms: Mark-sweep 1315.7 (1446.3) -> 1308.6 (1448.8) MB, 613.1 / 0.0 ms  (average mu = 0.070, current mu = 0.040) allocation failure scavenge might not succeed


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x3aa9ebf5be3d]
Security context: 0x37c8eea1e6e9 <JSObject>
    1: /* anonymous */(aka /* anonymous */) [0x37c895d8d969] [/Users/nick/Projects/origin/node_modules/terser-webpack-plugin/node_modules/webpack-sources/lib/applySourceMap.js:~58] [pc=0x3aa9ed4fe2c4](this=0x37c83a5026f1 <undefined>,chunk=0x37c803a7d979 <String[14]: createElement(>,middleMapping=0x37c8171046d9 <Object map = 0x37c835e45c79>)
    2: SourceNode...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10003cf99 node::Abort() [/usr/local/bin/node]
 2: 0x10003d1a3 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 3: 0x1001b7835 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 4: 0x100585682 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 5: 0x100588155 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/bin/node]
 6: 0x100583fff v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 7: 0x1005821d4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
 8: 0x10058ea6c v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 9: 0x10058eaef v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
10: 0x10055e434 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
11: 0x1007e6714 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
12: 0x3aa9ebf5be3d 
13: 0x3aa9ed4fe2c4 
14: 0x3aa9ed4b7d28 
Abort trap: 6

Code

https://github.com/OriginProtocol/origin/blob/master/dapps/marketplace/webpack.config.js

How Do We Reproduce?

git clone https://github.com/OriginProtocol/origin.git
cd origin
# Update dapps/marketplace/package.json to use v2.0.0 of terser plugin
yarn
cd dapps/marketplace
yarn build
Reacted by Andrey Marchenko, Endi, Stav Alfi, Dmitri K, Anthony, Max Henash, Hieu Pham (Web SRE / Platform Pillar), François Bonnefont, Gabriel Meola, Memmie Lenglet and 7 more
Reacted by albertogaldames, Zofia Góralewska-Wojtysiak, Max Henash and Gabriel Meola

Activity

Next
  1. nick
    changed the title [-]Process aborts with our of memory when using 2.0.0[/-] [+]Process aborts with 'out of memory' when using 2.0.0[/+] on Sep 6, 2019
  2. alexander-akait commented on Sep 6, 2019

    @alexander-akait
    alexander-akait
    on Sep 6, 2019
    Member
    More actions

    Thanks for issue, investigate

  3. alexander-akait commented on Sep 6, 2019

    @alexander-akait
    alexander-akait
    on Sep 6, 2019
    Member
    More actions

    Just information, change this line to:

    "build:js": "NODE_ENV=production webpack --progress --loglevel notice",
    

    and see what happens.

    Error appears on source map generation step:

    93% after chunk asset optimization SourceMapDevToolPlugin app.9949447c.js generate SourceMap`
    

    Use sourceMap: false fix problem, increase memory for node also fix problem. I keep investigation.

  4. alexander-akait commented on Sep 6, 2019

    @alexander-akait
    alexander-akait
    on Sep 6, 2019
    Member
    More actions

    Looks terser leaking

    Reacted by Jake Romer, Sibelius Seraphini, Charles, anggonoou, Mert Köseoğlu and Ivan (don_vanchos) Ergunov
  5. alexander-akait commented on Sep 6, 2019

    @alexander-akait
    alexander-akait
    on Sep 6, 2019
    Member
    More actions

    Why problem appears:
    Here we change logic 8b88b39

    Before for only one file we run new thread for uglification, now we use same thread for this. Removing tasks.length > 1 from https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/src/TaskRunner.js#L48 fix problem. Why we do this - try to reduce memory and cpu usage when you have only one file (creating new thread takes more memory and increase cpu loading).

    But another problem occurred - memory leak. terser something doesn’t clear therefore the current thread began to consume more memory.

    Simple investigation, i used this code:

    const used = process.memoryUsage().heapUsed / 1024 / 1024;
    console.log(`The script uses approximately ${Math.round(used * 100) / 100} MB`);
    

    and put this lines after https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/src/index.js#L272

    New version (we don't create new thread for one file):

    The script uses approximately 1016.37 MB
    

    Old version (new thread for one file):

    The script uses approximately 362.56 MB
    

    Around 700 MB leaking

    /cc @fabiosantoscode

  6. alexander-akait commented on Sep 6, 2019

    @alexander-akait
    alexander-akait
    on Sep 6, 2019
    Member
    More actions

    /cc @nick also cache is not working with your code, because you always generate something new in code, don't use:

    BUILD_TIMESTAMP: +new Date()
    

    Caches is not working in your app, long cache term also

  7. alexander-akait commented on Sep 6, 2019

    @alexander-akait
    alexander-akait
    on Sep 6, 2019
    Member
    More actions

    @nick try to use https://github.com/webpack-contrib/terser-webpack-plugin/releases/tag/v2.0.1, anyway we need investigate why terser consume a lot of memory

    Let's wait @fabiosantoscode answer

  8. nick commented on Sep 6, 2019

    @nick
    nick
    on Sep 6, 2019
    Author
    More actions

    Thanks for looking this so quickly, @evilebottnawi - and thanks for the tip on the cache issue 😊

    Can confirm 2.0.1 works as before. Feel free to close unless you want to keep it open for the memory issue.

  9. fabiosantoscode commented on Sep 6, 2019

    @fabiosantoscode
    fabiosantoscode
    on Sep 6, 2019
    Contributor
    More actions

    Interesting. I'll try to come up with the exact tag where this started to happen.

  10. fabiosantoscode commented on Sep 6, 2019

    @fabiosantoscode
    fabiosantoscode
    on Sep 6, 2019
    Contributor
    More actions

    But I kind of have something else I have to fix first, though.

  11. alexander-akait commented on Sep 6, 2019

    @alexander-akait
    alexander-akait
    on Sep 6, 2019
    Member
    More actions

    @fabiosantoscode 👍 yep, feel free to ping me i can help you with memory leak searching

  12. fabiosantoscode commented on Sep 9, 2019

    @fabiosantoscode
    fabiosantoscode
    on Sep 9, 2019
    Contributor
    More actions

    I tried creating a file that attempts to encrypt a lot of things to try and create a memory leak, but I can't reproduce this at all. I looked into the commit that fixes this. Isn't this just a 2.0.0 specific problem?

  13. alexander-akait commented on Sep 9, 2019

    @alexander-akait
    alexander-akait
    on Sep 9, 2019
    Member
    More actions

    @fabiosantoscode no, we just run terser in separate thread instead using currently, but looks terser have memory leak, because no problem in parallel mode, but problem when you use only one thread

  14. fabiosantoscode commented on Sep 10, 2019

    @fabiosantoscode
    fabiosantoscode
    on Sep 10, 2019
    Contributor
    More actions

    Can this be reproduced with the default options? The Terser tests aren't leaking memory at all.

  15. eliseumds commented on Sep 10, 2019

    @eliseumds
    eliseumds
    on Sep 10, 2019
    More actions

    In my experience, there hasn't been any significant difference in memory usage. Both V1 and V2 are hovering around 500MB of memory (and same compilation time) for one of our smaller apps. Measured with NODE_ENV=production time -l ... on MacOS. The dependencies are basically the same (Node, Webpack, etc).

  16. 73 remaining items

  17. didierofrivia
    added a commit that references this issue on Jan 27, 2020

    [webpacker] Fix out of memory.

    5d261c9
  18. alexander-akait commented on Jan 27, 2020

    @alexander-akait
    alexander-akait
    on Jan 27, 2020
    Member
    More actions

    I think I was able to solve this problem, big thanks @cjlarose for inspiration and great idea, honestly I don’t know how I didn’t get to this decision before. Now I run tests to put them here, I think today we release a patch version and close that problem.

    I want to warn that this reduces consumption, but for real big projects, for example 5000+ entries, you need increase node memory usage

    Reacted by Fábio Santos, Andrey Marchenko, baco16g, Max Henash, Charles and anggonoou
  19. alexander-akait
    closed this as completedin #211on Jan 28, 2020
  20. alexander-akait commented on Jan 28, 2020

    @alexander-akait
    alexander-akait
    on Jan 28, 2020
    Member
    More actions

    Release will be today, evening, want to add more tests (increase coverage)

    Reacted by Pavel Pustovalov, Yves M., Nick R, Max Henash and Sibelius Seraphini
    Reacted by Yves M. and Nick R
    Reacted by Yves M. and Max Henash
  21. didierofrivia
    added a commit that references this issue on Jan 29, 2020

    [circle] Fix out of memory.

    0e4b3c4
  22. sayamindu
    added 2 commits that reference this issue on Jul 16, 2020

    Set parallel to 1 for TerserPlugin

    e8752cf

    Set parallel to 1 for TerserPlugin

    e05425c
  23. nick-funk
    added 3 commits that reference this issue on Jan 4, 2022

    Update terser-webpack-plugin to 3.1.0 or greater

    2028b78

    Up terser-webpack-plugin to v4.2.3

    a64377f

    Set terser parallelism to 4

    78bb4d0
  24. kodiakhq
    added a commit that references this issue on Jan 5, 2022

    Fix memory leak during Docker builds (#3832)

    0a7eb86
  25. nick-funk
    added a commit that references this issue on Jan 5, 2022

    Fix memory leak during Docker builds (#3832)

    7702c35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.