Polymer CLI构建内存不足

时间:2016-09-26 09:29:27

标签: polymer polymer-1.0 polymer-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删除一些组件,它会构建但是它不是我真正想要的吗?

更新2:可能的解决方法

不要破坏一切。内联一些进口。认为它的工作围绕着这个问题,因为构建工具更有可能在“更大”的包中找到类似的依赖关系,并能够将它们组合在一起。而不是必须将它们包含在所有捆绑中。

1 个答案:

答案 0 :(得分:0)

这样我才能关闭它。

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