聚合物CLI构建耗尽内存



我很惊讶,当我在实现更多组件后运行polymer build时,它耗尽了内存。这怎么可能?我不会认为我的网站/应用非常大……

info:    Building application...
info:    Generating build/unbundled...
info:    Generating build/bundled...
<--- Last few GCs --->
  105411 ms: Mark-sweep 1343.6 (1434.7) -> 1343.0 (1434.7) MB, 1430.6 / 0 ms [allocation failure] [GC in old space requested].
  106857 ms: Mark-sweep 1343.0 (1434.7) -> 1343.0 (1434.7) MB, 1446.6 / 0 ms [allocation failure] [GC in old space requested].
  108349 ms: Mark-sweep 1343.0 (1434.7) -> 1343.0 (1434.7) MB, 1491.5 / 0 ms [last resort gc].
  109808 ms: Mark-sweep 1343.0 (1434.7) -> 1342.6 (1434.7) MB, 1459.5 / 0 ms [last resort gc].

<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x24b44a0c9e31 <JS Object>
    2: nextToken [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/lib/node_modules/polymer-cli/node_modules/acorn/dist/acorn.js:~2459] [pc=0x313c0f47bb3b] (this=0x3618e7c0f981 <a Parser with map 0x18a29db9aa01>)
    3: next [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/lib/node_modules/polymer-cli/node_modules/acorn/dist/acorn.js:2413] [pc=0x313c0ee10d47] (this=0x3618e7c0f981 <a Parser with map 0x...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 4: v8::internal::Factory::NewFixedArray(int, v8::internal::PretenureFlag) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 5: v8::internal::FullCodeGenerator::PopulateDeoptimizationData(v8::internal::Handle<v8::internal::Code>) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 6: v8::internal::FullCodeGenerator::MakeCode(v8::internal::CompilationInfo*) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 7: v8::internal::Compiler::EnsureDeoptimizationSupport(v8::internal::CompilationInfo*) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 8: v8::internal::OptimizedCompileJob::CreateGraph() [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
 9: v8::internal::Compiler::GetOptimizedCode(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ConcurrencyMode, v8::internal::BailoutId, v8::internal::JavaScriptFrame*) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
10: v8::internal::(anonymous namespace)::CompileOptimized(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ConcurrencyMode) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
11: v8::internal::Runtime_CompileOptimized_Concurrent(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/limjiewmeng/.nvm/versions/node/v6.4.0/bin/node]
12: 0x313c0e50961b
13: 0x313c0e538279
[1]    8057 abort      polymer build

在详细模式下运行给了我一些提示:

debug:   accept: bower_components/iron-behaviors/iron-control-state.html
debug:   accept: bower_components/paper-ripple/paper-ripple.html
debug:   accept: bower_components/paper-styles/color.html
debug:   accept: bower_components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html
debug:   accept: bower_components/iron-behaviors/iron-control-state.html
debug:   accept: bower_components/paper-ripple/paper-ripple.html
debug:   accept: bower_components/paper-styles/color.html
debug:   accept: bower_components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html
debug:   accept: bower_components/iron-behaviors/iron-control-state.html
debug:   accept: bower_components/paper-ripple/paper-ripple.html
debug:   accept: bower_components/paper-styles/color.html
debug:   accept: bower_components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html

看起来像是在循环运行?

我注意到,如果我从polymer.json中删除一些组件,它会构建,但它不是我真正想要的?

UPDATE 2:可能的解决方法

不要把所有东西都碎片化。内联一些导入。认为它的工作围绕着这个问题,因为构建工具更有可能在"较大"的包中找到类似的依赖项,并能够将它们分组在一起。而不是将它们包含在所有bundle中。

这样我就可以关闭它了。

似乎问题在于创建了太多的bundle。因此,我没有动态加载(几乎)每个单独的组件(后来我发现这可能不是一个好主意),而是开始将类似的东西分组在一起,包括在一个bundle中。这为我解决了这个问题。

相关内容

  • 没有找到相关文章

最新更新